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

Answer Posted / dinesh

#include<stdio.h>
#include<conio.h>
void main()
{
char name1[20],name[20];
int i,j,c=0;
clrscr();
printf("enter two strings");
scanf("%s%s",name1,name);
for(i=0,j=0;name1[i]!='\0'||name[j]!='\0';i++,j++)
{
if(name1[i]!=name[j])
{
c++;
}
}
if(c==0)
printf("equal strings");
else
printf("not equal strings");
}

Is This Answer Correct ?    10 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

1) write a program to generate 1st n fibonacci prime numbers using Nested if 2) write a program to generate twin prime numbers from m to n using nested if 3) write a program to check whether a given integer is a strong number or not using nested if 4) Write a program to generate prime factors of a given integer using nested if 5)write a program to generate prime numbers from m to n using nested if 6)write a program to generate perfect numbers from m to n using nested if 7)write a program to generate the pallindromes from m to n using neste if 8)write a program to generate armstrong numbers from m to n using nested if 9)write a program to generate strong numbers from m to n using nested if

3967


Create a simple code fragment that will swap the values of two variables num1 and num2.

793


Differentiate between functions getch() and getche().

608


Why n++ execute faster than n+1 ?

1817


regarding pointers concept

1559






Why is extern used in c?

601


At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these names could be kept in that shelf as in this example: bottom of shelf ---> [AAAJKRDFDEWAAYFYYKK]-----Top of shelf. All these packets are to be loaded on cars. The cars are lined in order, so that the packet could be loaded on them. The cars are also named [A, B, C, D, E,………….]. Each Car will load the packet with the same alphabet. So, for example, car ‘A’ will load all the packets with name ‘A’. Each particular car will come at the loading point only once. The cars will come at the loading point in alphabetical order. So, car ‘B’ will come and take all the packets with name ‘B’ from the shelf, then car ‘C’ will come. No matter how deep in the shelf any packet ‘B’ is, all of the ‘B’ packets will be displaced before the ‘C’ car arrives. For that purpose, some additional shelves are provided. The packets which are after the packet B, are kept in those shelves. Any one of these shelves contains only packets, having the same name. For example, if any particular shelf is used and if a packet with name X is in it, then only the packets having names X will be kept in it. That shelf will look like [XXXXXXX]. If any shelf is used once, then it could be used again only if it is vacant. Packets from the initial shelf could be unloaded from top only. Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

1721


Differentiate between the expression “++a” and “a++”?

687


What are derived data types in c?

597


Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent

1633


What are qualifiers and modifiers c?

533


What is the process of writing the null pointer?

595


Explain how can a program be made to print the line number where an error occurs?

680


What are the types of c language?

539


What is %g in c?

601