The examination committee of the university has decided to give 5 grace marks to every student of a class. Assume that there are list of students in the class and their marks are stored in a list called marksList. Write a program that adds the grace marks to every entry in the marksList.
C Programming Language Array in C Language (Article) Array in C Language (Program)
564Program:
/* This program adds grace marks to all elements of a list of marks */ #include void main() { int marksList[5]; int i; int grace = 5; /*grace marks */ /* Read the marksList */ printf ("\n Enter the list of marks one by one \n"); for (i = 0; i < 5; i++) { scanf ("%d", &marksList[i]); marksList[i] = marksList[i] + grace; } /* Print the Final list */ printf ("\n The final List is ..."); printf ("\n S. No.\t Marks"); for (i = 0; i < 5; i++) printf ("\n %d\t%d", i, marksList[i]); }
Output:
Enter the list of marks one by one 50 51 52 53 54 The final List is ...
Explanation:
It may be noted that in the above program, a component by component processing has been done on the all elements of the array called marksList.
This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.