Home / Programs / 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.
🚀 Programming Example

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.

👁 808 Views
💻 Practical Program
📘 Step Learning

As the problem deals with a list of marks, we can select a one-dimensional array called ‘marksList’ to represent the list. The grace marks are to be added to all the elements of the list, for which we must use the For-loop. The required program is given below:

💻 Program Code

/* This program adds grace marks to all elements of a list of marks */
#include <stdio.h>
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]);
}
                        

🖥 Program 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.

📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.