write c++ program to read the input and check whether the number is positive, negative, or zero using the switch statement only
- برمجة سي بلس بلس
- 2021-12-03
- softwareEngineer
الأجوبة
#include <iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter any number: ";
cin>>num;
switch (num>0)
{
// Num is positive
case 1:
cout<<num<<" is positive.";
break;
// Num is either negative or zero
case 0:
switch (num < 0)
{
case 1:
cout<<num<<" is negative.";
break;
case 0:
cout<<num<<" is zero.";
break;
}
break;
}
return 0;
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال