This is my first day of learning c++
i want to develop a small scrip that works like this
If i enter 1 or 2 i come first and i get congratulated and then asked for contact details
If i enter 3 or 4 i come second and i get congratulated and then asked for contact details
If i enter any other number I get a message saying i lost and asked for contact details
This is what ive come up with so far
im having a problem that when i run the code and enter 1 or 2 i get congratulated and asked for contact details , thats all fine but later after entering them am greeted a sorry and asked for details again .Help me fix the code please
#include<iostream>
usingnamespace std;
int main() {
float x,y;
cout<<"please enter the value of x\n";
cin>>x;
if (x==1 ||x==2) {
cout<<"You are first\n";
cout<<"Cogratulations, you Won\n";
cout<<"Please enter your contact details so we can send you your gift\n";
cin>>y;
cout<<"THANK YOU\n";
}
if (x==3 ||x==4) {
cout<<"You are second\n";
cout<<"Cogratulations, you Won\n";
cout<<"Please enter your contact details so we can send you your gift\n";
cin>>y;
cout<<"THANK YOU\n";
}
else {
cout<<"Please try Again later\n";
cout<<"Enter your Contact details so we can get back to you for more future events\n";
cin>>y;
cout<<"THANK YOU\n";
}
system("pause");
}
#include<iostream>
#include<string.h>
usingnamespace std;
int main() {
float x;
string y;
cout<<"please enter the value of x\n";
cin>>x;
if (x==1 ||x==2) {
cout<<"You are first\n";
cout<<"Cogratulations, you Won\n";
cout<<"Please enter your contact details so we can send you your gift\n";
cin>>y;
cout<<"THANK YOU\n";
}
elseif (x==3 ||x==4) {
cout<<"You are second\n";
cout<<"Cogratulations, you Won\n";
cout<<"Please enter your contact details so we can send you your gift\n";
cin>>y;
cout<<"THANK YOU\n";
}
else {
cout<<"Please try Again later\n";
cout<<"Enter your Contact details so we can get back to you for more future events\n";
cin>>y;
cout<<"THANK YOU\n";
}
}