About swith

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{int a,b;
scanf("%d,%d",&a,&b);
{switch(a)
{case 0:cout<<"zero\t";break;
case 1:cout<<"one\t";break;
case 2:cout<<"two\t";break;
case 3:cout<<"three\t";break;
case 4:cout<<"four\t";break;
case 5:cout<<"five\t";break;
case 6:cout<<"six\t";break;
case 7:cout<<"seven\t";break;
case 8:cout<<"eight\t";break;
case 9:cout<<"nine\t";break;
}}
switch(b)
{case 0:cout<<"o'clock\n";break;
case 1:cout<<"one\n";break;
}
return0;
}


I hope when I put in a and b,
it print time.example, a=1,b=0,and print zero o'clock
but it didn't work.
and I can understand what is the problem.
please tell me what should I do

Start by putting in

cout << "a=" << a << "b=" << b << endl; so you can see what value is given to a and b, so that you can see what's going wrong.

Then type in
1,0
and see it work.

Then stop using scanf and use C++ instead; remove the scanf line and put in

1
2
cin >> a;
cin >> b;
Topic archived. No new replies allowed.