Riya is getting bored in AngelHack then Simran came with a game in which there is given a number N. If the number is divisible by 3 then Riya has to print Angel and if the number is divisible by 5 then she has to print Hack and if divisible by both then she has to print AngelHack! .If N does not satisfy any condition print the number as it is. Help Riya in printing the result.
Example:
Input: n = 6
Output: Angel
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){long long n = 6;if (n % 3 == 0 && n % 5 == 0)cout << "AngelHack!\n";else if (n % 3 == 0)cout << "Angel\n";else if (n % 5 == 0)cout << "Hack\n";elsecout << n << "\n";return 0;}
No comments:
Post a Comment