Site icon DataFlair

Student Marksheet Generation Based on Conditional Statements in C++

Master C++ with Real-time Projects and Kickstart Your Career Start Now!!

Program 1

// Project to Create MarkSheet of Student
#include<iostream>
using namespace std;
int main()
{
    int h,m,e,c,total,per,rno;
    string name;
    system("cls");
    cout<<"Enter Roll No: ";
    cin>>rno;
    cout<<"Enter Name: ";
    cin>>name;
    hindi:cout<<"\nEnter marks of Hindi:";
    cin>>h;
    if(h<0 || h>100)
     {
        cout<<"\nInvalid marks .. enter again";
        goto hindi;
     } 
     eng:cout<<"\nEnter marks of English:";
    cin>>e;
    if(e<0 || e>100)
     {
        cout<<"Invalid marks .. enter again";
         goto eng;
     } 
     math:cout<<"\nEnter marks of Maths:";
    cin>>m;
    if(m<0 || m>100)
     {
        cout<<"Invalid marks .. enter again:";
         goto math;
     } 
     comp:cout<<"\nEnter marks of Computer:";
    cin>>c;
    if(c<0 || c>100)
     {
        cout<<"Invalid marks .. enter again";
         goto comp;
     } 
     total=(h+e+c+m);
     per=total/4;
     cout<<"\n-----------------------------";
     cout<<"\nRoll No: "<<rno;
     cout<<"\nName: "<<name;
     cout<<"\nTotal Marks is: "<<total;
     cout<<endl<<"Percentage: "<<per<<"%";
     if(per<35)
       cout<<"\n Fail";
     else if(per>=35 && per<45)  
        cout<<"\n III Divsion";
     else if(per>=45 && per<60)  
        cout<<"\n II Divsion";
     else if(per>=60)
         cout<<"\n I Divsion";
     cout<<"\n-----------------------------";

    return 0;
}
Exit mobile version