Program Based On String
2.
Write a program to accomplish the followings:-Read any two string. Say sti and st2.-Compare sti and st2 and display the corresponding messageaccording to the following criteria:If (sti =st2) thendisplay “Both strings are equal”elsedisplay “Both strings are not equal”
#include<stdio.h>#include<conio.h>#include<string.h>void main(){char str1[25],str2[25];int i=0,flag;clrscr();printf("Enter String-1 : ");scanf("%[^\n]s",&str1);printf("Enter String-2 : ");scanf("%[^\n]s",&str2);while(str1[i]!='\0'){if(str1[i]==str2[i]){flag=1;}else{flag=0;}i++;}if(flag==0){printf("Both Strings Are Equal.");}else{printf("Both Strings Are Not Equal.");}getch();}
Path :- F:\MCA I Sem\FOP\Final\String - 2 - Roll No :- 04MCA54
Leave a Comment