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 is int main () in c?
How pointer is different from array?
How will you divide two numbers in a MACRO?
What are header files in c programming?
write a c programming using command line argument,demonstrate set operation(eg;union,intersection,difference) example output is c:>setop 12 34 45 1 union 34 42 66 c:>setop 12 34 1 42 66 c:>setop 12 34 diff 12 56 67 78 setop 12 34
Write a program on swapping (100, 50)
How can I invoke another program or command and trap its output?
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?
Explain what does it mean when a pointer is used in an if statement?
Why array is used in c?
What is %d called in c?
What are integer variable, floating-point variable and character variable?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
Can i use “int” data type to store the value 32768? Why?
What is use of bit field?