HHW 9

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

HW - Puja Break

Date of Submission 21.10.2022

Program 1

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

A positive integer is called a spy number if the sum and product of its digits are equal. In other
words, a number whose sum and product of all digits are equal is called a spy number.

For ex 1124

Sum=1+1+2+4=8

Product=1*1*2*4=8

Program 2

Write a program that prints the absolute difference between a number and its reverse number.

For ex

Input 493

Output

Number=493

Reverse 394

Absolute difference= 99

Program 3

Write a program that inputs a number and checks whether it is a special two digit number or
not.

A number is said to be a special two digit number if the sum of its digits when added to the
product of the digits, is equal to the original number.

For ex 59

Sum=5+9=14

Product=5x9=45

Sum of sum of digits and product of digits=14+45=59

Hence, 59 is a special two digit number.

1
Program 4

Using switch statement, write a menu driven program for the following :
(i) To find and display the sum of the series given below :

𝒙 𝒙 𝒙 𝒙
S= + + +……………………
𝟐 𝟓 𝟖 𝟐𝟎

(ii) To display and display the first 10 terms of the series

4 16 36 64….

(iii)To display the product of first n natural numbers

F=1x2x3x……………………n

For an incorrect option, display ”Invalid choice”

Program 5

Design a menu driven program using switch case construct to

(a) Print the sum of the following series


x1 + x2 + x3 + ……………. xn terms

(b) To display the following series:


0, 7, 26, 63………….. p terms.

For an incorrect option, display ”Invalid choice”

Program 6
Write a program to input a number and check whetehr it is a perfect square or not.
A number is said to be a perfect number if its square root is an integer.
For ex 36,49

You might also like