C program for printing elements in a format
#include <stdio.h>
int main()
//driver function
{
int courseGrades[100];
int n,i;
printf("How much grades points were there");
scanf("%d",&n);
printf("Enter grade elements\n");
//Taking input from user
for(i=0;i<n;i++)
{
scanf("%d",&courseGrades[i]);
}
printf("Elements are \n");
//printing the elements that user entered
for(i=0;i<n;i++)
{
printf("%d",courseGrades[i]);
}
printf("\nPrinting elements in the format\n");
for(i=0;i<n;i++)
/*loop for the first line,\t is used for horizontal spacing*/
{
printf(" %d\t",courseGrades[i]);
}
printf("\n");
/*\n is used to get the new line*/
for(i=n-1;i>=0;i--)
/*loop for printing the input in reverse order*/
{
printf("%d \t",courseGrades[i]);
}
return 0;
}
<u>Output</u>
How much grades points were there 4 Enter grade elements {7,9,11,10}
Elements are
791110
Printing elements in the format
7 9 11 10
10 11 9 7