write a program to display the array elements in reverse
order in c language
Answer Posted / arpit dhandhania
Both the solution above is wrong...
Answer #1: It will input an extra element in array coz array is starting from 0 and goes till n so total elements n+1
Answer #2: C Automatically starts array from 0 index and not 1 if not programmed otherwise and in the given program we are starting the loop from 1
Solution
void main()
{
int a[30],n;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=n-1;i>=0;i--)
printf("%d",a[i]);
}
}
Is This Answer Correct ? | 65 Yes | 39 No |
Post New Answer View All Answers
What does static variable mean in c?
Is there any possibility to create customized header file with c programming language?
What is the difference between declaring a variable and defining a variable?
What is the return type of sizeof?
Why is python slower than c?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
what is different between auto and local static? why should we use local static?
Explain function?
Do you have any idea how to compare array with pointer in c?
What are the uses of null pointers?
Why is c fast?
What are header files? What are their uses?
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
What is #define in c?
What is typedef example?