need help im a beginner in c++ this is part of the code in our midterm exam
why does it close after i input the name of the professor
feedback is appreciated thanks
#include<iostream>
usingnamespace std;
int main()
{
int a, b;
cout<<"Enter name of Professor: \n";
cin>>a;
cout<<"Enter Level Code: \n";
cin>>b;
("pause");
return 0;
}
#include <iostream>
#include <string>
#include <cstdlib>
int main()
{
std::string name ;
std::cout << "Enter name of Professor (wthout spaces): " ;
std::cin >> name ; // read the name into a string
int level_code ;
std::cout << "Enter Level Code: " ;
std::cin >> level_code ; // // read the level code into an int
std::cout << "You entered name: " << name << " level code: " << level_code << '\n' ;
std::system( "pause" ) ;
}
Also, you are asking someone to input a name, which is a series of characters called a "string", into an integer variable. JL has ya fixed for that problem though.