I keep getting 0x488144 and another one before my output

Picture of error when input is jst L

#include <iostream> 

using namespace std;

int main() 
{
    string student_name;
    cout << "Enter student name\n";
    cin >> student_name;
    string student_surname;
    cout << "Enter Student surname\n";
    cin >> student_surname;
    string student_id;
    cout << "Enter Student ID\n";
    cin >> student_id;
    string student_group;
    cout << "Enter Student Group\n";
    cin >> student_group;
    string Module_code;
    cout << "Enter Module Code\n";
    cin >> Module_code;
    float test1;
    cout << "Enter Test 1 mark\n";
    cin >> test1;
    float test2;
    cout << "Enter Test 2 mark\n";
    cin >> test2;
    float final_mark;
    final_mark = (test1 + test2) / 2;
    cin >> final_mark;
    string grade;

    if (final_mark >= 80) {
        grade = "A";
        cin >> grade;
    }
    else if (final_mark >= 70) {
        cout << "B";
        cin >> grade;
    }
    else if (final_mark >= 60) {
        grade = "C";
        cin >> grade;
    }
    else if (final_mark >= 50) {
        grade = "D";
        cin >> grade;
    }
    else if (final_mark >= 40) {
        grade = "E";
        cin >> grade;
    }
    else (final_mark <= 30);
    {
        grade = "F";
        cin >> grade;
    } /*final code*/ cout << "LOMKOWKING UNIVERSITY\n";

    cout << "ESWATINI CAMPUS\n";
    cout << "STUDENT RESULT\n";
    cout << "STUDENT NAME :" << cout << student_surname << student_name << endl;
    cout << "STUDENT ID :" << cout << student_id << endl;
    cout << "STUDENT GROUP :" << cout << student_group << endl;
    cout << "MODULE CODE :" << cout << Module_code << endl;
    cout << "Test 1 :" << cout << test1;
    cout << "Test 2" << cout << test2 << endl;
    cout << "Final Mark :" << cout << final_mark;
    cout << "Grade :" << cout << grade << endl;
    return 0;
}

1 answer

  • answered 2022-01-13 10:01 Shriniwas Khond

    #include <bits/stdc++.h> 
    using namespace std;
    int main() {
    string student_name;
    cout<< "Enter student name\n";
    cin>>student_name;
    string student_surname;
    cout<<"Enter Student surname\n";
    cin>>student_surname;
    string student_id;
    cout<<"Enter Student ID\n";
    cin>>student_id;
    string student_group;
    cout<<"Enter Student Group\n";
    cin>>student_group;
    string Module_code;
    cout<<"Enter Module Code\n";
    cin>>Module_code;
    float test1;
    cout<<"Enter Test 1 mark\n";
    cin>>test1;
    float test2;
    cout<<"Enter Test 2 mark\n";
    cin>>test2;
    float avg;
    avg = (test1 + test2) / 2;
    string grade;
    
    if(avg<=40){
        grade = "F";
    }
    else if(avg<=50 && avg>40){
        grade = "E";
    }
    else if(avg<=60 && avg>50){
        grade = "D";
    }
    else if(avg<=70 && avg>60){
        grade = "C";
    }
    else if(avg<80 && avg>70){
        grade = "B";
    }
    else if(avg>=80){
        grade = "A";
    }
    
    /*final code*/
    
    cout<< "LOMKOWKING UNIVERSITY\n";
    cout<<"ESWATINI CAMPUS\n";
    cout<< "STUDENT RESULT\n";
    cout<< "STUDENT NAME :" <<student_surname << " " <<student_name << endl;
    cout<< "STUDENT ID :" <<student_id << endl;
    cout<< "STUDENT GROUP :"<<student_group << endl;
    cout<< "MODULE CODE :"<<Module_code << endl;
    cout<< "Test 1 :" <<test1<<endl;
    cout<< "Test 2: "<<test2 << endl;
    cout<< "Final score :"<<avg << endl;
    cout<< "Grade :"<<grade<<endl;
    return 0;
    }
    

    please, do not input "L" as a value to float variables (i.e. test1 and test2)

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum