Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > warning: multi-character character constant error

Reply
Thread Tools

warning: multi-character character constant error

 
 
emeraldsky23 emeraldsky23 is offline
Junior Member
Join Date: Jan 2011
Posts: 5
 
      01-15-2011
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 ()
{
char chem_reply;
cout << "Type in 'f' for frequency, 'w' for wavelength, and 'e' for energy: ";
cin >> chem_reply;
switch (chem_reply)
{
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':
char reply;
cout << "Is the frequency given?: ";
cin >> reply;
if (reply== 'yes' || reply=='Yes')
{
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 << "*";
}
if (reply == 'no' || reply == 'No')
{
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unicode + Escape Character = IE Unterminated string constant error! VUNETdotUS Javascript 3 11-02-2007 03:37 PM
"error C2057: expected constant expression", "error C2466: cannot allocate an array of constant size 0". Why doesn't my simple program work??? hn.ft.pris@gmail.com C++ 13 01-22-2007 02:03 PM
"Non-constant" constant can't be used as template argument Martin Magnusson C++ 2 10-08-2004 08:41 AM
Understanding How To Use #ifdef Constant #define Constant Sequence In Multible Files Christopher M. Lusardi C++ 1 09-02-2004 07:43 AM
warning: multi-character character constant...help me! mimmo C Programming 4 04-10-2004 08:15 PM



Advertisments