write a program of palindrome(madam=madam) using pointer?
Answers were Sorted based on User's Feedback
#include<conio.h>
#include<stdio.h>
void main()
{ char *a,*count,s[11];
int i ;
printf("\n:enter string for Palindrome test\t");
scanf("%s",&s);
i= strlen(s);
a=(char *)malloc(i*sizeof(char));
a=&s[0];
count=&s[i-1];
while((*(a++)==*(count--)) && i>=1)
{ i--; }
if(i==0) { printf("\n%s is a palin",s);}
else { printf("\n%s is not palin",s);}
getch();
}
Is This Answer Correct ? | 39 Yes | 7 No |
Answer / rajni
write a program for array to pointer and pointer of an
array?
Is This Answer Correct ? | 7 Yes | 0 No |
Answer / vikas
thank you
i needed this
do u hv any more questions-answer on pointer
Is This Answer Correct ? | 11 Yes | 6 No |
Answer / pradeep raj
int main()
{
char a[20],*p,*q;//p=>front pointer q=>back pointer
int flag=0;
cin >>a;
q=&a[0];
while(*q!='\0')
q++;
q--; // to the last character before null
for(p=&a[0];p!=q ;p++,q--)
{
if(*p==*q)
flag++;
if((q-p)==1)//to avoid even palindrome..
break;
}
if(flag==strlen(a)/2)
cout <<" is palindrome";
else
cout <<"not";
getch();
}
Is This Answer Correct ? | 3 Yes | 5 No |
Answer / priyanka
#include<stdio.h>
#include<conio.h>
int stpal(char str[50]);
void main()
{
char str[50];
int pal;
clrscr();
printf(“nnt ENTER A STRING…: “);
gets(str);
pal = stpal(str);
if(pal)
printf(“nt THE ENTERED STRING IS A PALINDROME”);
else
printf(“nt THE ENTERED STRING IS NOT A PALINDROME”);
getch();
}
int stpal(char str[50])
{
int i = 0, len = 0, pal = 1;
while(str[len]!=’′)
len++;
len–;
for(i=0; i<len/2; i++)
{
if(str[i] == str[len-i])
pal = 1;
else
{
pal = 0;
break;
}
}
return pal;
}
Is This Answer Correct ? | 2 Yes | 11 No |
please can some one guide me, to the answer Write a C program to enter 15 numbers as an input from the keyboard and program will find and print odd numbers and their average. i have studied while and do while loop for loop if and else if switch
What is sizeof int in c?
What is double pointer in c?
in one file global variable int i; is declared as static. In another file it is extern int i=100; Is this valid ?
Explain what is wrong in this statement?
what is foreign key in c language?
44.what is the difference between strcpy() and memcpy() function? 45.what is output of the following statetment? 46.Printf(“%x”, -1<<4); ? 47.will the program compile? int i; scanf(“%d”,i); printf(“%d”,i); 48.write a string copy function routine? 49.swap two integer variables without using a third temporary variable? 50.how do you redirect stdout value from a program to a file? 51.write a program that finds the factorial of a number using recursion?
Explain how do you determine whether to use a stream function or a low-level function?
Write a code to generate divisors of an integer?
What is an example of enumeration?
What are the advantages of c preprocessor?
#define MAX 3 main() { printf("MAX = %d ",MAX ); #undef MAX #ifdef MAX printf("Vector Institute”); #endif }