write a program to display the array elements in reverse
order in c language

Answer Posted / pandia

#include<stdio.h>
int main()
{
int a[]={1,2,3,7,8};
int count=0,i;
while(a[i] != '\0')
{
count++;
}
for(i=count;i>=1;i--)
{
printf("%d",a[i]);
}
}

Is This Answer Correct ?    33 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you subtract pointers from each other? Why would you?

559


What is a good data structure to use for storing lines of text?

601


Why dont c comments nest?

625


main() { printf("hello"); fork(); }

699


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

757






What is the correct declaration of main?

681


What is meant by errors and debugging?

651


What are run-time errors?

602


What are nested functions in c?

568


Explain what happens if you free a pointer twice?

615


why we wont use '&' sing in aceesing the string using scanf

1787


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

1580


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

648


What is difference between array and structure in c?

583


Explain how can you avoid including a header more than once?

606