InterviewSolution
Saved Bookmarks
| 1. |
Given the following code fragment: if(a==0)cout<<"Zero";if(a==1)cout<<"One";if(a==2)cout<<"Two";if(a==3)cout<<"Three";Write an alternative code (using if) that saves on number on compressions. |
|
Answer» #include<iostream.h> void main() { int a; cout<<"enter a:"; cin>>a; if(a==0) cout<<"Zero"; else if(a==1) cout<<"One"; else if(a==2) cout<<"Two"; else if(a==3) cout<<"Three"; else cout<<"other than 0,1,2,3"; |
|