Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Programming class assignment

Name :-lovekush kumar # roll no:-27600120018 #sec :-A stream -cse

Q3:- Write a program that will reverse the elements of an array?

#All programme are written and compiled in gnu gcc compiler code blocks.

# A c program to input numbers in an array and display that will reverse the elements of an array?

#algorithm
 Input the number of elements of an array.
 Input the array elements.
 Traverse the array from the last.
 Print all the elements.

# c programme for array element reverse


#include<stdio.h>

int main()

int a[100], i, j, Size, Temp;

printf("\nPlease Enter the size of an array: ");

scanf("%d",&Size);

for (i = 0; i < Size; i++)

scanf("%d", &a[i]);

j = i - 1;

i = 0;

while (i < j)

Temp = a[i];

a[i] = a[j];

a[j] = Temp;

i++;

j--;

}
Programming class assignment
Name :-lovekush kumar # roll no:-27600120018 #sec :-A stream -cse
printf("\nResult of an Reverse array is: ");

for (i = 0; i < Size; i++)

printf("%d \t", a[i]);

return 0;

#Input:-

Please Enter the size of an array: 5

#output:-

Result of an Reverse array is: 5 4 3 2 1


Programming class assignment
Name :-lovekush kumar # roll no:-27600120018 #sec :-A stream -cse

You might also like