Be sure to ONLY Program this problem in C
You are going to use an array and a function, and print the values of that array backwards. Here's some guidelines to follow to help you out:
1. Setup your array manually (whichever values you want are ok, with as many as you want, and whichever datatype you prefer. That's all fine).
2. Be sure to call your function by sending two parameters to such function: the array’s length and the array itself.
3. Inside the function, you'll have to print the array backwards.
4. Your function shouldn’t return anything.
Program:
#include<stdio.h>
//declaration(header declaration) of a function
void reverseArray(int[],int);
int main()
{
//suppose there are 10 elements in the array
int arr[10],i;
printf("Enter 10 elements: \n\n");
//storing values into the array
for(i=0;i<=9;i++)
{
scanf("%d",&arr[i]);
}
//calling the function with 2 parameters
reverseArray(arr,10); //it has two parameters(1. array, 2. length
of the array)
return 0;
}
//definition of the function
void reverseArray(int arr[],int size)
{
int i;
printf("\n\nPrinting the values of the array backwards:
\n\n");
for(i=size-1;i>=0;i--)
{
printf("%d\n",arr[i]);
}
}
Output:
Get Answers For Free
Most questions answered within 1 hours.