Here is alphabets : abcdefgh
1) how to reverse. as hgfedcba
2) after reversal, how to group them in a pair hg fe dc ba.
Answer Posted / 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 |
Post New Answer View All Answers
Explain why C language is procedural?
Can we replace the struct function in tree syntax with a union?
What is a program flowchart and how does it help in writing a program?
Why is a semicolon (;) put at the end of every program statement?
What is multidimensional arrays
What is data type long in c?
Can we change the value of constant variable in c?
What is build process in c?
What does c mean in basketball?
How can I open a file so that other programs can update it at the same time?
What is array in C
Is main is a keyword in c?
How can I discover how many arguments a function was actually called with?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
What the advantages of using Unions?