Here is alphabets : abcdefgh
1) how to reverse. as hgfedcba
2) after reversal, how to group them in a pair hg fe dc ba.
Answers were Sorted based on User's Feedback
Answer / srinivas
1)Ans:
its simple find the string length say K
now run a a loop from 0 to K/2 incrementing by 1 every time
and swap the elements as
for(i=0;i<K/2;i++)
{
temp=a[i];
a[i]=a[K-(i+1)]
a[K-(i+1)]=temp;
}/*this is to reverse the string*/
2)Ans:
for(i=0;i<K;i++)
{
printf("%c",a[i]);
if((i+1)%2==0)
printf(" ");
}/*this is for printing in groups*/
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / ruchi
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
int i,c;
char p[]="abcdefgh";
i=strlen(p);
for(c=i;c>=0;c--)
{
printf("%c",p[c]);
}
for(c=i;c>=0;c--)
{
printf("%c",p[c]);
if(c%2==0)
{
printf(" ");
}
}
getch();
}
Is This Answer Correct ? | 2 Yes | 1 No |
write a program to remove duplicate from an ordered char array? in c
Hi, main() { } Is a user defined function or Built in Functionn
What is the right way to use errno?
f1() { f(3);} f(int t) { switch(t); { case 2: c=3; case 3: c=4; case 4: c=5; case 5: c=6; default: c=0;} value of c?
what is a NULL pointer?
what is ur strangth & weekness
0 Answers Cognizant, LG Soft, NetEnrich,
Implement bit Array in C.
LOGIC OF Bodmas?
say the following declaration is correct nr not. int b=a,n=0;
Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014 Npu university
O,T,T,F,F,S,S,E,N,?,?,?,T,F,F,S,S,E,N
i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none