An efficient way to read your variables (#24844)

* An efficient way to read your variables

Instead of declaring the variable "grade" in a trivial way by giving it value directly from code,
we can enter it when we run the program, to make our code more dynamic and testing multiple situations
by just re-running the program and entering a different thing as an input, instead of modifying the variable
over and over again

* Cleaned up comment
This commit is contained in:
TrollzorFTW
2018-12-14 06:20:18 +02:00
committed by Manish Giri
parent 7936b91394
commit 4887c4316e

View File

@ -42,7 +42,12 @@ using namespace std;
int main () {
// local variable declaration:
char grade = 'D';
/* You can also have the user enter the value of grade to make your code more dynamic, like so:
char grade;
cin >> grade;
*/
switch(grade) {
case 'A' :
cout << "Excellent!" << endl;
@ -63,7 +68,7 @@ int main () {
cout << "Your grade is " << grade << endl;
return 0;
}```
}
Output:
You passed