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
- For Loop
- Discussions
For Loop
For Loop
+ 0 comments int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int a, b; std::vector<std::string> words = {"zero","one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "even", "odd"}; scanf("%d\n%d", &a, &b); for(int i = a; i <= b; i++){ if(i > 9) { if(i%2 == 0) cout << words[10 + i%2] << endl; else cout << words[10 + i%2] << endl; } else{ cout << words[i] << endl; } } return 0; }
+ 0 comments include
include
using namespace std;
int main() { int a,b,n; cin>>a>>b>>n; string arr[ ]={"one", "two" ,"three", "four" , "five", "six", "seven","eight", "nine"}; for(int n=a;n<=b;n++) { if(n<=9){ cout<9 && n%2==0){ cout<<"even"<
return 0;
}
+ 0 comments It cant get better
#include <iostream> #include <vector> int main() { std::vector<std::string> words = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; int begin, end; std::cin >> begin >> end; for (int i = begin; i <= end; ++i) { if (i <= 9) std::cout << words[i] << std::endl; else std::cout << (i % 2 == 0 ? "even" : "odd") << std::endl; } return 0; }
+ 0 comments Here are the solution of For Loop in C++ Hacker Rank Solution
+ 0 comments include
include
using namespace std;
int main() { // Complete the code. int a,b; cin >>a; cin >>b;
int n; cin>>n; for(int i=a;i<=b;i++){ if(i>=1&&i<=9){ switch(i){ case 1: cout<<"one \n"; break; case 2: cout<<"two \n"; break; case 3: cout<<"three \n"; break; case 4: cout<<"four \n"; break; case 5: cout<<"five \n"; break; case 6: cout<<"six \n"; break; case 7: cout<<"seven \n"; break; case 8: cout<<"eight \n"; break; default: cout<<"nine \n"; break; } } else if(i>9&&i%2==0) cout<<"even \n"; else cout<<"odd \n"; } return 0;
}
Load more conversations
Sort 1427 Discussions, By:
Please Login in order to post a comment