We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Introduction
- Conditional Statements
- Discussions
Conditional Statements
Conditional Statements
Sort by
recency
|
862 Discussions
|
Please Login in order to post a comment
Kind of cheated using an array, but it's cleaner:
// Write your code here if(n==1) { cout<<"one"<
}
int main() { string n_temp; getline(cin, n_temp);
}
if (n == 5){ cout << "five" << endl; } else if(n == 8){ cout << "eight" << endl; } else if(n > 9){ cout << "Greater than 9" << endl; } else{ cout << "error" << endl; }
// Write your code here n==1?cout<<"one":n==2?cout<<"two":n==3?cout<<"three":n==4?cout<<"four":n==5?cout<<"five":n==6?cout<<"six":n==7?cout<<"seven":n==8?cout<<"eight":n==9?cout<<"nine":cout<<"Greater than 9";