- 1

Write a program to check whether a number is a magic number or not.

1st Apr 2018, 9:49 AM
Indraneel Bhattacharya
Indraneel Bhattacharya - avatar
3 ответов
+ 2
#include <stdio.h> bool is_magic_number(int a) { return ((a % 9) == 1); } int main() { // Print out all 'magic' numbers, that are less than a hundred. for (int i = 0; i < 100; i++) { if (is_magic_number(i)) { printf("%d\n", i); } } }
1st Apr 2018, 10:21 AM
Emma
+ 4
What magic number are you talking about?
1st Apr 2018, 10:10 AM
Tomer Sim
Tomer Sim - avatar
+ 2
Numbers that give 1 as remainder when divided by 9
1st Apr 2018, 10:11 AM
Indraneel Bhattacharya
Indraneel Bhattacharya - avatar