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 difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
What is the difference between exit() and _exit() function?
What is difference between union and structure in c?
Explain the advantages and disadvantages of macros.
What is the method to save data in stack data structure type?
Are the variables argc and argv are always local to main?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
What is mean by data types in c?
Why can’t constant values be used to define an array’s initial size?
What is structure padding in c?
What is function what are the types of function?
How we can insert comments in a c program?
Why c is a procedural language?
What are the three constants used in c?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)