Write a program to compare two strings without using the
strcmp() function
Answer Posted / ria varughese
#include <stdio.h>
#include <string.h>
void stringcmp(char s1[], char s2[]);
int main()
{
char str1[10],str2[10];
printf("\nEnter first String:");
scanf("%s",str1);
printf("\nEnter second String:");
scanf("%s",str2);
stringcmp(str1,str2);
return 0;
}
void stringcmp(char *s1, char *s2)
{
int i,j;
for(i=0;s1[i]!='\0';i++)
{
for(j=0;s2[j]!='\0';j++)
{
if(s1[i] == s2[j])
continue;
}
}
if (i==j)
{
printf("String s1:%s and s2:%s are EQUAL\n",s1,s2);
}
else
printf("String s1:%s and s2:%s are NOT EQUAL\n",s1,s2);
}
Is This Answer Correct ? | 84 Yes | 89 No |
Post New Answer View All Answers
Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.
Explain union.
What is c system32 taskhostw exe?
What is wrong in this statement? scanf(ā%dā,whatnumber);
Explain about the functions strcat() and strcmp()?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
#include
Explain what are multibyte characters?
How can I copy just a portion of a string?
How many types of errors are there in c language? Explain
Explain what is a pragma?
What is a protocol in c?
Why is c so important?
what are non standard function in c
Can static variables be declared in a header file?