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

Answer Posted / premkumar

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()

{
clrscr();
int c=0;
char a[10];

char b[10];
gets(a);
gets(b);
for(int i=0,j=0;b[i]!='\0'||a[j]!='\0';i++,j++)
{
if(a[i]!=b[j])
{
c++;

}

}
if(c==0)
cout<<"string match";
else
cout<<"string does not match";

getch();
}

Is This Answer Correct ?    69 Yes 24 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer

752


How many parameters should a function have?

655


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

599


Can you mix old-style and new-style function syntax?

652


What are the primitive data types in c?

562






How can I implement a delay, or time a users response, with sub-second resolution?

611


What is call by value in c?

546


in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

591


If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402

3238


Can we increase size of array in c?

525


What is a macro in c preprocessor?

616


What is s in c?

596


How can you tell whether two strings are the same?

817


Tell me when would you use a pointer to a function?

594


Explain the Difference between the New and Malloc keyword.

674