Write a program to compare two strings without using the
strcmp() function
Answer Posted / abhishek
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<conio.h>
void main()
{
clrscr();
char a[100],b[100];
int i,m;
cout<<"enter first string";
gets(a);
cout<<"enter second string";
gets(b);
for(i=0;a[i]!='\0'&&b[i]!='\0';i++)
{
if(a[i]!=b[i])
{
c=1;
}
}
if(c==1)
{cout<<"the strings do not match!";
}
else
{
cout<<"the strings match!";
}
getch();
}
| Is This Answer Correct ? | 7 Yes | 9 No |
Post New Answer View All Answers
Explain what are reserved words?
What are the 4 types of programming language?
Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.
Differentiate call by value and call by reference?
Why is c platform dependent?
How can I read/write structures from/to data files?
List some basic data types in c?
Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.
How pointers are declared?
What is volatile variable how do you declare it?
What is hungarian notation? Is it worthwhile?
What do you mean by scope of a variable in c?
What is difference between structure and union with example?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
What would happen to X in this expression: X += 15; (assuming the value of X is 5)