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

What is an lvalue in c?

694


What is const and volatile in c?

565


What is the purpose of main() function?

651


Why pointers are used in c?

582


When is a null pointer used?

640






What is line in c preprocessor?

613


What is the process to generate random numbers in c programming language?

608


What are near, far and huge pointers?

644


What is the best way to comment out a section of code that contains comments?

780


why programs in c are running with out #include? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

1317


How can I read a binary data file properly?

635


What is c programing language?

612


What are void pointers in c?

574


How is a structure member accessed?

583


Explain why c is faster than c++?

572