Write a program to compare two strings without using the
strcmp() function
Answer Posted / navy
#include<stdio.h>
#include<conio.h>
void main()
{
char s1[20];
int i, j, len=0, flag=0;
printf("\nEnter any string: ");
gets(s1);
for (i=0; s1[i]!='\0'; i++)
len++;
i = 0;
j = len-1;
while (i < len)
{
if (s1[i] != s1[j])
{
flag = 1;
break;
}
i++;
j--;
}
if (flag == 0)
printf("\nString is palindrome");
else
printf("\nString is not palindrome");
getch();
}
Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
What is an array in c?
How are structure passing and returning implemented?
How can I get random integers in a certain range?
In C language what is a 'dangling pointer'?
What the different types of arrays in c?
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?
we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?
Explain how can a program be made to print the line number where an error occurs?
What is identifiers in c with examples?
Can a pointer be volatile in c?
Simplify the program segment if X = B then C ← true else C ← false
Write a program to check armstrong number in c?
The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.
How many main () function we can have in a project?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?