OUTPUT (after running):
Enter the size of the array: 10
Enter the array elements: 1 2 3 4 5 8 9 10 20 30
Largest element is: 30
Please note here that when an array is passed as an argument then the base address of the
array (i.e., the address of the first element) is passed. Also note that by default the array is
passed by reference only.
Q4.
Write a C program that reads 10 integer elements, reverses them, and then displays them.
Solution 4:
The program is as follows:
#include
void main( )
{
int a[10], i;
clrscr( );
printf(“\n\tEnter your 10 array elements:”);
for(i=0; i<10; i++)
scanf(“%d”, &a[i]);
printf(“\nThe list in reverse order is:”);
for(i=9; i>=0; i- -)
printf(“%d”, a[i]);
getch( );
}
Do'stlaringiz bilan baham: |