Print the marks using return type and arguments in C


This program is a C program that calculates the total marks and average of five subjects and determines the grade based on the total marks and whether the student passed or failed.

  • The header file "stdio.h" is included, which contains the standard input/output library functions.
  • The "void marks()" function is declared, which will perform the calculation of total marks and average and determine the grade based on the total marks.
  • The "main()" function is defined as the starting point of the program.
  • The "marks()" function is called in the "main()" function using the "marks()" function call statement.
  • The "marks()" function definition follows the function declaration.
  • Five integer variables "tam", "eng", "mat", "sci", "soc", "tot", and "avg" are declared.
  • The "printf()" function is used to print the prompt "Enter the marks:".
  • The "scanf()" function is used to get the marks of five subjects from the user.
  • The sum of the marks of five subjects is stored in the "tot" variable.
  • The average of the marks of five subjects is calculated and stored in the "avg" variable.
  • The "printf()" function is used to print the result "Total Marks:%d" and "Average:%d" along with the values stored in the "tot" and "avg" variables.
  • A conditional statement is used to determine the grade based on the total marks. If the total marks are greater than 230, the student is considered to have passed, and the grade is determined based on the total marks.
  • If the total marks are less than 230, the student is considered to have failed, and the message "Fail" is printed.
  • The "return 0;" statement in the "main()" function is used to indicate that the program executed successfully.

Source Code Example : 1

#include<stdio.h>
void marks();
int main()
{
   marks();
   return 0;
}
void marks()
{
   int tam,eng,mat,sci,soc,tot,avg;
   printf("\nEnter the Marks:");
   scanf("%d%d%d%d%d",&tam,&eng,&mat,&sci,&soc);
   tot=tam+eng+mat+sci+soc;
   avg=tot/5;
   printf("\nTotal Marks:%d",tot);
   printf("\nAverage:%d",avg);
   if(tot>230)
   {
      if(tot>=480)
      {
        printf("\nGrade:A");
      }
      else if(tot>400&&tot<480)
      {
        printf("\nGrade:B");
      }
      else if(tot<400)
      {
        printf("\nGrade:C");
      }
      printf("\nPass");
   }
   else
   {
    printf("\nFail");
   }
}
To download raw file Click Here

Output

Enter the Marks:99
87
96
95
96
Total Marks:473
Average:94
Grade:B
Pass


This program is about print the marks with return value and with argument using functions.

Source Code Example : 2

#include<stdio.h>
int marklist(int,int,int,int,int);
int main()
{
   int tam,eng,mat,sci,soc,tot,avg,ans;
   printf("\nEnter the Marks:");
   scanf("%d%d%d%d%d",&tam,&eng,&mat,&sci,&soc);
   ans=marklist(tam,eng,mat,sci,soc);
   printf("\nTotal:%d",ans);
   avg=ans/5;
   printf("\nAverage:%d",avg);
   return 0;
}
int marklist(int tam,int eng,int mat,int sci,int soc)
{
   int tot;
   tot=tam+eng+mat+sci+soc;
   return tot;
}         
To download raw file Click Here

Output

Enter the Marks:98
96
95
97
99
Total Marks:485
Average:97




This program is about print the marks no return value and with argument using functions.

Source Code Example : 3

#include<stdio.h>
void marklist(int,int,int,int,int);
int main()
{
   int tam,eng,mat,sci,soc,avg;
   printf("\nEnter the Marks:");
   scanf("%d%d%d%d%d",&tam,&eng,&mat,&sci,&soc);
   marklist(tam,eng,mat,sci,soc);
   return 0;
}
void marklist(int tam,int eng,int mat,int sci,int soc)
{
   int avg,tot;
   tot=tam+eng+mat+sci+soc;
   printf("\nTotal marks:%d",tot);
   avg=tot/5;
   printf("\nAverage mark:%d",avg);
   if(tot>250)
   {
      printf("\nPass");
   }
   else
   {
      printf("\nFail");
   }
}
 
To download raw file Click Here

Output

Enter the Marks:98
96
95
97
99
Total Marks:485
Average:97
Pass

This program is about print the marks with return value and without argument using functions.

Source Code Example : 4

include<stdio.h>
int marklist();
int main()
{
   int avg,total;
   total=marklist();
   printf("\nTotal marks:%d",total);
   avg=total/5;
   printf("\nAverage:%d",avg);
   return 0;
}
int marklist()
{
   int tam,eng,mat,sci,soc,tot,avg,ans;
   printf("\nEnter the Marks:");
   scanf("%d%d%d%d%d",&tam,&eng,&mat,&sci,&soc);
   tot=tam+eng+mat+sci+soc;
   return tot;
}       
To download raw file Click Here

Output

Enter the Marks:98
96
95
97
99
Total Marks:485
Average:97

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C