conversion program

help please. I'm trying to create a conversion program that lets the user choose a unit first then converting it to other units
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
41
42
43
44
45
46
47
48
49
50
51
52
  #include<iostream>
#include<conio.h>
using namespace std
;main()
{
	char A,B,C,D;
	double x,n,n1,n2,n3;
	cout<<"Input number: ";
	cin>>x;
	cout<<"\nChoose a unit: "<<"\n\tA.Inch \n\tB.Centimeter\n\tC.Feet\n\tD.Meter "<<endl;
	cin>>n;
	
	if(n='A')
	{
	n1=x*2.54;
	cout<<"Centimeteter: "<<n1<<endl;
	n2=x*0.0833333;
	cout<<"Feet: "<<n2<<endl;
	n3=x*0.0254;
	cout<<"Meter: "<<n3<<endl;
	}
	else if  (n='B')
	{
	n1=x*0.393701;
	cout<<"Inch: "<<n1<<endl;
	n2=x*0.0328084;
	cout<<"Feet: "<<n2<<endl;
	n3=x*0.01;
	cout<<"Meter: "<<n3<<endl; 
 	}
	else if  (n='C')
	{
 	n1=x*12;
	cout<<"Inch: "<<n1<<endl;
	n2=x*30.48;
	cout<<"Centimeter: "<<n2<<endl;
	n3=x*0.3048;
	cout<<"Meter: "<<n3<<endl; 
 	}
 	else if (n='D');
	{
 	n1=x*39.3701;
	cout<<"Inch: "<<n1<<endl;
	n2=x*3.28084;
	cout<<"Feet: "<<n2<<endl;
	n3=x*100;
	cout<<"Centimeter: "<<n3<<endl; 
 	}

 	return 0;
	getch();
Use == instead of =

= is use for assigment, not comparing
It works now. But the outputs keep on repeating even when I choose a different letter
n here is float not char, try change it to char and remove some unused variables
Topic archived. No new replies allowed.