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
What is the use of ?
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given
What are valid signatures for the Main function?
how to count no of words,characters,lines in a paragraph.
How is = symbol different from == symbol in c programming?
What is putchar() function?
What is cohesion and coupling in c?
Write a Program to accept different goods with the number, price and date of purchase and display them
Why c is a mother language?
Tell us the use of fflush() function in c language?
What is difference between structure and union in c?
How do we open a binary file in Read/Write mode in C?
if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0
what is the different bitween abap and abap-hr?
What is wild pointer in c?