Help a beginner in the programing world.

Hi! First of all i would like to say that i'm just starting my adventure with C++ and overall programing.

So, i have a question, how do i build a program to convert from quinary to 15(i dunno how this numeral system is called in english). I have already build a program to convert from binary to decimal, now i want to try something harder but i feel like i cannot quite do it. Oh, and this converter has to be build only with iostream libary.

And also why doesn't this code work? It has to convert roman digits to arabic ones.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 #include <iostream>

using namespace std;

int main()
{
int a;
cin>>a;
if (a=1);
cout<<"I";
if (a=5);
cout<<"V";
if (a=10);
cout<<"X";
if (a=50);
cout<<"L";
if (a=100);
cout<<"C";
if (a=500);
cout<<"D";
if (a=1000);
cout<<"M";

}


Thanks for any potential answers, you will really help me. :)
By the way im so sorry for any grammar mistakes, im not a native speaker.
And also why doesn't this code work?


a=1 sets the value of a to 1.

a==1 compares the value of a with 1.


Also, you've put a semi-colon right after every if statement. This is wrong.

1
2
if (a==1);
cout<<"I";

is the same as
1
2
3
4
5
if (a==1)
{

}
cout<<"I";

but
1
2
if (a==1)
cout<<"I";

is the same as
1
2
3
4
if (a==1)
{
  cout<<"I";
}
Last edited on
Thank you for your reply, i forgot some basic things, haven't programmed in a while. It was nice of you to help me, i appreciate it.

This just leaves my numeral system converter. :)
Topic archived. No new replies allowed.