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 |
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
Difference between data structure and data base.
7 Answers CTS, Value Labs, Zoho,
How to find a missed value, if you want to store 100 values in a 99 sized array?
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM
increment operateor (++)and decrament(--) #include<stdio.h> #inclide<conio.h> main() { int x=15; while(x!=0) scanf("%d",&x); {
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
main() { unsigned int k = 987 , i = 0; char trans[10]; do { trans[i++] =(char) (k%16 > 9 ? k%16 - 10 + 'a' : '\0' ); } while(k /= 16); printf("%s\n", trans); }
What is the output of the program given below #include<stdio.h> main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }
21 Answers ADITI, Student, TCS,
EXPLAIN #INCLUDE<STDIO.H> EXPLAIN #INCLUDE<CONIO.H>
Hai what is the different types of versions and their differences
Write an interactive c program that will encode or decode a line of text. To encode a line of text, proceed as follows: Convert each character, including blank spaces, to its ASCII equivalent. Generate a positive random integer. Add this integer to the ASCII equivalent of each character. The same random integer will be used for the entire line of text. Suppose that N1 represents the lowest permissible value in the ASCII code, and N2 represents the highest permissible value. If the number obtained in step 2 above exceeds N2, then subtract the largest possible multiple of N2 from this number, and add the remainder to N1. Hence the encoded number will always fall between N1 and N2, and will therefore always represent some ASCII character. Display the characters that correspond to the encoded ASCII values. The procedure is reversed when decoding a line of text. Be certain, however, that the same random number is used in decoding as was used in encoding.
1 Answers Amazon, CSJM, HCL, Microsoft, TCS, Wipro,
Can we replace the struct function in tree syntax with a union?