currect code, wrong resault.
Jul 30, 2010 at 8:13pm Jul 30, 2010 at 8:13pm UTC
Hi!
my name is reza.
I write this code:
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
//This program uses switch with char variable.
#include <iostream>
using namespace std;
#include <conio.h>
int main(){
int n1, n2;
bool control=true ;
char opt;
while (control){
system("cls" );
cout<<"Enter number1 and oporator and number2 :" ;
cin>>n1>>opt>>n2;
switch (opt){
case '+' :
cout<<"\n" <<n1+n2;
break ;
case '-' :
cout<<"\n" <<n1-n2;
break ;
case '*' :
cout<<"\n" <<n1*n2;
break ;
case '/' :
cout<<"\n" <<n1/n2;
break ;
default :
cout<<"\n operation is not legal" ;}
getch();
}
return 0;}
a blank window opens and nothing happens i cannot type anything inside it. i cannot cose it. after few minutes it closes automaticly.
I amusing:
windows 7.
kaspersky 9.
visual C++ 6.
Jul 30, 2010 at 9:51pm Jul 30, 2010 at 9:51pm UTC
Works fine for me...
I'm using:
Win7
Code::Blocks (IDE)
BTW, you might want to check for division by zero, or the application will fail.
Topic archived. No new replies allowed.