Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

" ; " after loop



Working with switch case



Comment



Test expression



Specifer




String_ compare two string




// AHF C PROGRAM SOLVING

//solving here 2_D   ARRAY 	programming problem

#include #define pf printf int main() { int i,len1,len2,flag=0; char str1[100],str2[100]; 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); //comparing two string if(len1!=len2) { pf("\nThe two string are not equal.\n"); //finding large string if(len1>len2) pf("\nFirst string is grater than second string.\n"); else pf("\nSecond string is grater than first string.\n"); } else { for(i=0;str1[i]!='\0';i++) { //comparing character by character of two string if(str1[i]!=str2[i]) { flag=1; break; } } //giving final output by comparing character by character if(flag==0) pf("\nThe two string are equal.\n"); else pf("\nThe two string are not equal.\n"); } return 0; }
OUTPUT:


© 2018 - All rights reserved