palindrome for strings and numbers----Can anybody do the
prog?
Answer Posted / shruti
//the palindrome for string can also be written as below,
without using inbuilt functions.
void main()
{
char str[10];
int flag = 0;
int i , j;
puts("ENTER THE STRING");
fflush(stdin);
gets(str);
for(i = 0 ; str[i] != '\0' ; i++);
i--;
for(j = 0 ; j<i ; j++ , i--)
{
if(str[j] == str[i])
flag = 1;
else
{
flag = 0;
break;
}
}
if(flag == 1)
puts("STRING IS A PALINDROME");
else
puts("STRING IS NOT A PALINDROME");
}
| Is This Answer Correct ? | 4 Yes | 3 No |
Post New Answer View All Answers
What is getch c?
Is boolean a datatype in c?
When should volatile modifier be used?
if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0
What is wrong in this statement? scanf(ā%dā,whatnumber);
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
Are the outer parentheses in return statements really optional?
What does sizeof function do?
Why is this loop always executing once?
Why we use void main in c?
Can you write the function prototype, definition and mention the other requirements.
List the difference between a 'copy constructor' and a 'assignment operator' in C?
What does do in c?
What are preprocessor directives in c?
How are 16- and 32-bit numbers stored?