what i need to do is to input a value and if it's false then i will need to input another value again in the same statement without repeating it..so basically my previous "cin" value is gone in the output..
what I only know
Pincode: 123456 (if wrong the Pincode still remains)
Pincode: (Pincode repeats itself so i can input again which is not what i need to do)
output should be like this..
Pincode: 123456 (if its wrong i will need to input something in the Pincode again but the statement
Pincode should not be repeated but i will still be able to input beside it)
arrghh its hard to explain it like this lol
if the value is wrong
Pincode:123
this should happen
Pincode:
not repeating it with the word "Pincode"
and there still this..
Welcome Guest!
Pincode:
thats the output if the pincode is not yet entered..so when i input the correct pincode it will become like this
Welcome President!
Pincode:123456
again not repeating the statement
the codes that i was just able to make where a simple cout and cin nothing else..please do tell me nicely to explain it again if you can't understand :)
#include <iostream>
usingnamespace std;
int main()
{
cout<<" Welcome Guest!"; //have to change "Guest" to "President" if pin is correct without repeating the statement
cout<<endl;
string pin;
for (;pin!="123456";)//i just use for loop more often
{
cout<<"Pincode: ";
getline(cin,pin);
//what happens here is, if i input the wrong pin it repeats the
//cout<<"Pincode: ";
//getline(cin,pin);
/*but what I need is to repeat cin without repeating the cout<<"Pincode"; which means
when i retype the pin value i will still be typing beside the FIRST "Pincode:" the first value
that i inputted will be replaced and that is where i type again...its like starting all over again/*
}
return 0;
} */
#include <iostream>
#include <stdlib.h>
usingnamespace std;
int main()
{
string pin;
for (;pin!="123456";)//i just use for loop more often
{
cout<<" Welcome Guest!"<<endl;
cout<<"Pincode: ";
getline(cin,pin);
system("CLS");
}
cout<<" Welcome President!"<<endl;
return 0;
}
sorry ive seen the output wrong..problem solved with system("CLS");
1 2 3 4 5 6
int priority;
for(;priority!=1||priority!=2||priority!=3||priority!=4||priority!=5;)
{
cout<<"Enter Priority Number: ";
cin>>priority;
}
am i doing this right?cuz even if i enter 1,2,3,4 or 5 the loop still continues
1 2 3 4 5 6
int priority;
for(;priority!=1;)
{
cout<<"Enter Priority Number: ";
cin>>priority;
}
this works though..but i need the 5 numbers..and if i enter a letter it won't proceed to a infinite loop but it will ask to enter priority number again