Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What does sizeof function do?

1199


Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?

1070


What is the advantage of a random access file?

1203


What is break in c?

1049


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

1107


What is struct node in c?

1075


How can I find out if there are characters available for reading?

1111


What are the types of variables in c?

1023


Explain what is the difference between functions getch() and getche()?

1056


What is the difference between if else and switchstatement

1936


Tell us bitwise shift operators?

1095


What is the acronym for ansi?

1051


What are header files in c programming?

1137


How can I split up a string into whitespace-separated fields?

1058


What happens if a header file is included twice?

1037