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 sizeof function do?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
What is the advantage of a random access file?
What is break in c?
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What is struct node in c?
How can I find out if there are characters available for reading?
What are the types of variables in c?
Explain what is the difference between functions getch() and getche()?
What is the difference between if else and switchstatement
Tell us bitwise shift operators?
What is the acronym for ansi?
What are header files in c programming?
How can I split up a string into whitespace-separated fields?
What happens if a header file is included twice?