Display marksheet using function in C++


Example Program

Here is the simple program for printing marksheet using function in C++.

Source Code Example : 1

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

Output

Enter the Marks:78
65
98
86
78
Total Marks:405
Average:81
Grade:B
Pass

Source Code Example : 2

#include<iostream>
using namespace std;
void marklist(int,int,int,int,int);
int main()
{
    int tam,eng,mat,sci,soc,avg;
    cout<<"\nEnter the Marks:";
    cin>>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;
    cout<<"\nTotal marks:"<<tot;
    avg=tot/5;
    cout<<"\nAverage mark:"<<avg;
    if(tot>250)
    {
        cout<<"\nPass";
    }
    else
    {
        cout<<"\nFail";
    }
}
To download raw file Click Here

Output

Enter the Marks:89
87
87
67
89
Total marks:419
Average mark:83
Pass

Source Code Example : 3

#include<iostream>
using namespace std;
int marklist(int,int,int,int,int);
int main()
{
    int tam,eng,mat,sci,soc,tot,avg,ans;
    cout<<"\nEnter the Marks:";
    cin>>tam>>eng>>mat>>sci>>soc;
    ans=marklist(tam,eng,mat,sci,soc);
    cout<<"\nTotal:"<<ans;
    avg=ans/5;
    cout<<"\nAverage:"<<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:90
80
70
60
50
Total:350
Average:70

Source Code Example : 4

#include<iostream>
using namespace std;
int marklist();
int main()
{
    int avg,total;
    total=marklist();
    cout<<"\nTotal marks:"<<total;
    avg=total/5;
    cout<<"\nAverage:"<<avg;
    return 0;
}
int marklist()
{
    int tam,eng,mat,sci,soc,tot,avg,ans;
    cout<<"\nEnter the Marks:";
    cin>>tam>>eng>>mat>>sci>>soc;
    tot=tam+eng+mat+sci+soc;
    return tot;
}
To download raw file Click Here

Output

Enter the Marks:90
80
70
60
50
Total marks:350
Average:70

Basic Programs


Flow Control

IF Statement Examples


Switch Case

Goto Statement

Break and Continue

While Loop

Do While Loop

For Loop

Friend Function in C++


String Examples


Array Examples


Structure Examples


Structure & Pointer Examples


Structure & Functions Examples


Enumeration Examples


Template Examples


Functions


List of Programs


Pointer Examples


Memory Management Examples


Pointers and Arrays


Virtual Function Examples



Learn All in Tamil © Designed & Developed By Tutor Joes