# warning: multi-character character constant error

Discussion in 'C Programming' started by emeraldsky23, Jan 15, 2011.

1. ### emeraldsky23

Joined:
Jan 15, 2011
Messages:
4
0
Hi, I'm new to this forum and I'm just starting off using C++. Anyway here is the problem: I'm trying to make a program that does chemistry calculations for me. Here is the code:

#include <iostream>
using namespace std;
int main ()
{
cout << "Type in 'f' for frequency, 'w' for wavelength, and 'e' for energy: ";
{
case 'f':
case 'F':
{
long double c = 3.00e+8;
long double wavelength;
long double frequency;
cout << "Enter wavelength: ";
cin >> wavelength;
frequency = c/wavelength;
cout << "The frequency is *" << frequency << "*.";
}
break;
case 'w':
case 'W':
{
long double c= 3.00e+8;
long double frequency;
long double wavelength;
cout << "Enter frequency: ";
cin >> frequency;
wavelength = c/frequency;
cout << "The wavlength is *" << wavelength << "*.";
}
break;

case 'e':
case 'E':
cout << "Is the frequency given?: ";
{
long double h= 6.626e-34;
long double energy;
long double frequency;
cout << "Enter frequency: ";
cin >> frequency;
energy = h*frequency;
cout<< "The energy of the wave is *" << energy << "*";
}
{
long double h= 6.626e-34;
long double c= 3.00e+8;
long double wavelength;
long double energy;
cout << "Enter wavelength: ";
cin >> wavelength;
energy = (h*c)/wavelength;
cout << "The energy of the wave is *" << energy << "*";
}
break;
}
}

The problem is when i ask it to do an energy calculation which, as you can see, has 'if' statements in it. The program doesn't go any further than asking me to type in whether I am give the frequency. After I type it, the code just simply ends.

emeraldsky23, Jan 15, 2011