1.

Write a C program to rearrange the elements of an array so that those originally stored at odd suffixes are placed before those at even suffixes

Answer»

A C program to rearrange the elements of an array so that those originally stored at odd suffixes are placed before those at even suffixs:

main()

{

char a[25],ch,temp;

int i;

clrscr();

printf ("\nEnter the string:-> ");

gets(a);

for (i=0;a[i]!='\0';i++)

{

if (a[i+1]=='\0')break;

temp=a[i];

a[i]=a[i+1];

a[i+1]=temp;

i++;

}

puts(a); getch();

}  



Discussion

No Comment Found

Related InterviewSolutions