Write a program to compare two strings without using the
strcmp() function

Answer Posted / raghu

#include<stdio.h>
#include<conio.h>
void main()
{
char a[100],b[100];
int i,c;
clrscr();
printf("enter first string");
scanf("%s",&a);
printf("enter second string");
scanf("%s",&b);
for(i=0;a[i]!='\0'&&b[i]!='\0';i++)
{
if(a[i]!=b[i])
{
c=1;
}
}
if(c==1)
{
printf("the strings do not match!");
}
else
{
printf("the strings match!");
}
getch();
}

Is This Answer Correct ?    8 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the application of c?

848


what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values

1470


What are control structures? What are the different types?

856


What is the explanation for modular programming?

919


What is substring in c?

875


In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

1620


What is the maximum length of an identifier?

909


Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?

797


What are multibyte characters?

862


What is const volatile variable in c?

797


How do I swap bytes?

843


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

1175


What is a node in c?

744


What is the role of && operator in a program code?

808


How can you increase the size of a statically allocated array?

857