Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Test expression



Working with switch case



Header file



Comment



" ; " after loop




String_ CMP - strcmp function




// AHF C PROGRAM SOLVING

//solving here CHARACTER MANIPULATION FUNCTION ( CMP ) 	programming problem

#include<stdio.h> #include<string.h> #define pf printf int main() { char str1[100],str2[100]; int len1,len2; //input data pf("Enter the first string: "); gets(str1); pf("\nEnter the second string: "); gets(str2); //counting first string length len1=strlen(str1); //counting second string length len2=strlen(str2); //checking equality if(strcmp(str1,str2)==0) pf("\nTHE TWO STRING ARE EQUAL."); else { if(len1>len2) //compare length { pf("\nTHE TWO STRING ARE NOT EQUAL."); pf("\nstr1 is grater than str2.\n"); } else if(len2>len1) { pf("\nTHE TWO STRING ARE NOT EQUAL."); pf("\nstr2 is grater than str1.\n"); } else pf("\nTHE TWO STRING ARE EQUAL BUT NOT SAME.\n"); } return 0; }
OUTPUT:


© 2018 - All rights reserved