How do i do this?

Here's my code:
#include <iostream>
#include <string>
using namespace std;

int main()
{
int x;
cin >> x;
{
if (x = 1)
{
cout << abc + "1 are I .\n";
}
}
{
if (x == 2)
{
cout << abc + "2 are II .\n";
}
}
{
if (x == 3)
{
cout << abc + "3 are III .\n";
}
}
{
if (x == 4)
{
cout << abc + "4 are IV .\n";
}
}
{
if (x == 5)
{
cout << abc + "5 are V .\n";
}
}
{
if (x == 6)
cout << abc + "6 are VI .\n";
}
{
if (x == 7)
cout << abc + "7 are VII .\n";
}
{
if (x == 8)
cout << abc + "8 are VIII .\n";
}
{
if (x == 9)
cout << abc + "9 are IX .\n";
}
{
if (x == 10)
cout << abc + "10 are X .\n";
}
system("pause");
return 0;
}

I left out some parts but that's not important. When i run the program, i enter e.g. 1 and it gives me I. But immediately after that the message Press any key to continue... appears. What i need to do to make it constantly wait for my input? I mean if i enter 1, it gives me I. But after that, it again waits for my input so i can enter 3 or 4 ... I hope you understand :D . Please help...
I know there are a lot of blocks :D
Last edited on
i dont know if it is just a mistype, and has nothing to do with your issue, but shouldn't if(x = 1) be if(x == 1)
Thanks. But can you help me with my problem?
are you familiar with do/while loops?
Correction: loops in general.
well 2 things
1. try using cin.ignore(); and then cin.get() that will make it wait for you to press enter first.
2. never use system(whatever) i
No. Just a little, but i'd say no. Can you tell me where to put do and where while in my code? I've read a lot of tutorials, but can't find a way to implement it in my code.
yes,, loops in general,, here is an example of a do/while loop that you can apply to your code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;

int main()
{
	int a;
	do 
	{
	
	cout << "please input 1 then enter to quit and any other input to continue,,,";
	cin >>  a;
	
	
	} while(a!=1);
	
return 0; 
}
Topic archived. No new replies allowed.