I recently came across the issue of not being able to type in my cmd console. I was working on a project in MSV; while starting a new one I was unable to type in the console. *After compiling with no errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
//@author Will A. Training Exercise Grade Programming
int main()
{
int grade = NULL;
bool repeat = true;
std::cout<<"Grade Programming Created By Will A.\n";
while(repeat)
{
if((grade <=100)&&(grade >=90))
{
std::cout<<"Your grade is an A\n";
}
}
}
Although in another project I worked on previously I still may type in the console.
#include <iostream>
usingnamespace std;
//@author Will A. Training Exercise Grade Programming
int main()
{
int grade = NULL;
char repeat = 'y';
cout<<"Grade Programming Created By Will A" << endl;
while(repeat == 'y')
{
cout<<"Enter your grade:" << endl;
cin >> grade;
if((grade <=100)&&(grade >=90))
{
cout<<"Your grade is an A"<< endl;
}
cout<<"Enter a new grade? Y OR N:" << endl;
cin >> repeat;
system("cls");
}
return 0;
}
Here is what I came up with very quickly. The while loop is currently unnecessary but I left it in for your sake.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
//@author Will A. Training Exercise Grade Programming
int main()
{
int grade = NULL;
bool repeat = true;
std::cout<<"Grade Programming Created By Will A.\n";
std::cout << "Enter your grade: ";
std::cin >> grade;
while(repeat){
if((grade <=100)&&(grade >=90))
{
std::cout<<"Your grade is an A\n";
}
}
}
I asked my friend whom has experience in c++. (Early till this moment)
He said it doesn't make much a difference in this case. Thanks for telling me that, I'll make sure to use that to the best of my knowledge.