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

Answer #2: You have assigned the elements of the array in
the program itself which by default starts from array index
0 that is the numbers goes into the array indices 0 1 2 3
4 and you have not initialzed or modified the value of i in
the first loop which happens to be a garbage or 0 so the
count goes to infinite. coz a[i] is never '\0'
Secondly in a numeric array last element in not null
character it is only in case of character arrays.
Assuming that you have implemented the 1st loop correctly
and you have the length of array a in count ie = 4 since u
are starting from 0 then you have initialized i to count
which makes i = 4.In the second loop the condition is i>=1
so i=0 is never visited and thus a[0] ir not displayed
(remember in C array starts from 0 by default).

Is This Answer Correct ?    5 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

find out largest elemant of diagonalmatrix

2254


how to count no of words,characters,lines in a paragraph.

4431


What is a constant?

1063


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

1128


Why can't I perform arithmetic on a void* pointer?

1100


write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

2808


What is the right type to use for boolean values in c?

1039


What are the advantages and disadvantages of a heap?

1215


When is a null pointer used?

1117


#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

1060


How can I remove the trailing spaces from a string?

1077


write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...

1938


What is the symbol indicated the c-preprocessor?

1252


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1091


if p is a string contained in a string?

1851