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
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
How many parameters should a function have?
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?
Can you mix old-style and new-style function syntax?
What are the primitive data types in c?
How can I implement a delay, or time a users response, with sub-second resolution?
What is call by value in c?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
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
Can we increase size of array in c?
What is a macro in c preprocessor?
What is s in c?
How can you tell whether two strings are the same?
Tell me when would you use a pointer to a function?
Explain the Difference between the New and Malloc keyword.