10 Mar 2013

COMPARE strings

/*

program to compare two strings....

*/

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
 

void main()
{
 

clrscr();
 

char a[50],b[50];
int i,j,k=0;
 

cout<<"Enter the first string:"<<endl;
gets(a);
cout<<"Enter the second string:"<<endl;
gets(b);
 

if(strlen (a)!=strlen (b))
 cout<<"Strings are not equal."<<endl;
else
 {
  for(i=0,j=0;a[i]!='\0';i++,j++)
 {
  if(a[i]==b[j])
   continue;
  else
   k=1;
   break;
 }
if(k>0)
 cout<<"Strings are not equal."<<endl;
else
 cout<<"Strings are equal."<<endl;
}


getch();
}


Categories: , ,

Related Posts:

  • pattern_nested loops /* program in c to print following pattern... &  &  &  &  &  &  &    &  &  &  &  &       … Read More
  • perfect_number /*  program to check whether a given no. is a ""perfect no."" or not. a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors e… Read More
  • graplin level-1 solved /* solution to graplin inline challenge level-1 */ #include<stdio.h>#include<conio.h>#include<string.h>void cutstr(char *,int ,int );char arr1[150]={'\0'};char arr2[150]={'\0'};char arr11[]="… Read More
  • Inverse_matrix /*   program to find inverse of a matrix...   */ #include<stdio.h> int main() {   int a[3][3],i,j;   float determinant=0;   printf("Enter the 9 elements of matrix: "… Read More
  • Palindrome_String /* program to check whether a string is palindrome or not in c++ */ #include<iostream.h>#include<conio.h>#include<string.h>#include<stdio.h>void main(){clrscr();int i,j,k,flag=0;char a[80];cout&… Read More

0 comments:

Post a Comment

Copyright © 2025 UPgradeCODING | Powered by Blogger