How do I reverse an array in C?

                                            How can we do reverse an array in C 

Logic to print array in reverse order:

  1. Take the num and element of the array variable from the user.
  2. Take I variable for looping.
  3. Run the for loop from I=num-1 to I >=0 and decrement the value of I.
  4. print the array element that is arr[i].
Let’s see an example of it:

       
  1. #include<stdio.h> 
  2. int main() 
  3. { 
  4. int num , arr[num] , i; 
  5. printf("Enter the size of an array:"); 
  6. scanf("%d",&num); 
  7. for(i=0;i<num;i++) 
  8. { 
  9. scanf("%d",&arr[i]); 
  10. }  
  11. printf("Reverse of an array of the element:"); 
  12. for(i = num-1; i >= 0; i--) 
  13. { 
  14. printf("%d\n",arr[i]); 
  15. } 
  16. return 0; 
  17. } 

Comments

Popular posts from this blog

proassignment help backlink data index 41

Programming shark backlink data index 67

programming shark backink data index 31