Help me Please

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


MY CODE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  #include<iostream>
using namespace 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");



}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<iostream>
#include<string.h>
using namespace 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";

                  }

     else 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";
      }



}
Topic archived. No new replies allowed.