if you define int i; and you set i =12; then its all other remaining characters are also is integer that not consistent 12 but they are only integers because you are defined a integer so that this happen other wise your loop run infinitely without any pause for input
#include <iostream>
using namespace std;
int main() {
// Write C++ code here
cout << "enter a number 1 or 0"<<endl;
int i;
cin>>i;
while(i!=0 || i!=1){
cout<<"you enterd wrong key enter 0 or 1 "<<endl;
cin>>i;
}
if(i==0){
cout<<" @ 0"<<endl;
}
if(i==1){
cout<<" @ 1"<<endl;
}
return 0;
}
in this program after entering in while loop if you press any keyword that is not a integer then the loooooop run infinitely and without any pause for input .... if you enter integer keyword in loop but that is not required key so the while loop again run but in this type you are able to insert your input of integer 💚😂 samjhe
Please give more details about it , so i can clear my confusion
ReplyDelete