answersLogoWhite

0

A "sunny number" is a whole number, n, such that the square root of n+1 is a whole number.

#include<stdio.h>

#include<math.h> // for sqrt

bool is_sunny (int n) {

int s = sqrt (++n);

return s*s==n;

}

int main (void) {

// print sunny numbers in the half-closed range [0:100)

for (int n=0; n<100; ++n) {

if (is_sunny (n)) {

printf ("%d is a sunny number\n");

} else {

printf ("%d is not a sunny number\n");

}

}

return 0;

}

User Avatar

Wiki User

8y ago

What else can I help you with?

Related Questions

Write a java program to print 'Sunny' Numbers till 'n'?

class Sunny { void accept(int n) { int n1=n+1; double x=Math.sqrt(n1); if((int)x==x) System.out.println("sunny number"); else System.out.println("not a sunny number"); } }


How do you write a c program to convert binary to decimal by using while statement?

write a c++ program to convert binary number to decimal number by using while statement


What is a sunny number?

A number, N, is a sunny number if N + 1 is a perfect square.


What is the code of a c program that will read in a positive integer value and determine If the integer is a prime number and If the integer is a Fibonacci number?

see the program


C plus plus program to print number patterns?

bghjg


Write a C program to convert hexadecimal number into decimal number?

pongada punda vayanungala ..................


When is a number called a 'Sunny' number?

A number is said to be 'sunny' when, 1 added to that number, the square root of it becomes a whole number...


A program c plus plus on automorphic numbers or not?

how to write a program that counts automorphic number from 1 to 999


What is sunny deol mobile number?

+919872735133is no.is sunny


How do you Write a C program to reverse an Integer number.?

Reference:cprogramming-bd.com/c_page2.aspx# reverse number


How do you write a C program to check whether the number is odd or even Ps-using DEV complier?

To write a C program to determine if something is odd or even you need to be a programmer. To write a program in C is complicate and only done by programmers.


Write a programme for substraction of two numbers in c language?

substracion of any two number program in c