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
Can two or more operators such as and be combined in a single line of program code?
What is the use of void pointer and null pointer in c language?
State the difference between realloc and free.
What type of function is main ()?
What is difference between structure and union?
What is pass by value in c?
What is action and transformation in spark?
What is strcmp in c?
Which is an example of a structural homology?
What is the meaning of typedef struct in c?
What is the difference between printf and scanf )?
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?
Why c is a procedural language?
What is substring in c?
What are lookup tables in c?