adspace


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


Please Help Members By Posting Answers For Below Questions

Is int a keyword in c?

1059


write a progrmm in c language take user interface generate table using for loop?

2124


What are compound statements?

1292


What is the general form of a C program?

1100


what is ur strangth & weekness

2592


Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.

2400


Do you know the difference between malloc() and calloc() function?

1135


How do you determine the length of a string value that was stored in a variable?

1205


`write a program to display the recomended action depends on a color of trafic light using nested if statments

2216


What is pointers in c with example?

1169


What is pointer to pointer in c with example?

1200


How can I implement sets or arrays of bits?

1119


write a c program to find the sum of five entered numbers using an array named number

2248


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2516


hi send me sample aptitude papers of cts?

2252