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


Please Help Members By Posting Answers For Below Questions

Can two or more operators such as and be combined in a single line of program code?

798


What is the use of void pointer and null pointer in c language?

616


State the difference between realloc and free.

619


What type of function is main ()?

574


What is difference between structure and union?

588






What is pass by value in c?

590


What is action and transformation in spark?

585


What is strcmp in c?

589


Which is an example of a structural homology?

768


What is the meaning of typedef struct in c?

579


What is the difference between printf and scanf )?

581


typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?

1060


Why c is a procedural language?

570


What is substring in c?

628


What are lookup tables in c?

540