The issue is that I have initialized Char variable as Q so that the LOOP does not execute but Sadly it does?! I could not find the logical flow in this operation what am I doing wrong, Why the LOOP executes even though it should not.
#include <iostream>
#include <vector>
using namespace std;
int main()
{
cout<<"This program is giving you some options, each option allows you to perform actions"<<endl;
char options{'Q'};
vector <int> numbers {1,2,3,4,5,6,7,8,9,10};
while (options != 'Q' || options != 'q' ){
cout << " P - Print numbers "<<endl;
cout << " A - Add a number "<<endl;
cout << " M - Display ,eam of the numbers"<<endl;
cout << " S - Display the smallest number "<<endl;
cout << " L - Display the largest number"<<endl;
cout << " Q - Quit"<<endl;
cout << " Enter your choice : " <<endl;
cin >> options;
// Printing Numbers
if (options =='P' || options =='p'){
for (auto x : numbers){
cout <<x<<endl;
}
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire