Number Programs for Absolute Beginners :
LEVEL 1 à
1. WAP in C/
C++/ java to perform the following tasks :
a. Accept two
numbers from the user( a and b).
b. Print the
numbers.
c. Print the
smallest number.
d. Calculate
their :
i.
Summation (a+b)
ii.
Subtract them (a-b)
iii.
Multiply them (a*b)
iv.
Divide them (a/b – quotient)
v.
Remainder (a%b)
vi.
Square root of each numbers.
2. WAP in C/
C++/ java to print the even numbers between
M and N ( 0> M,N <100 )
3. WAP in C/
C++/ java to find the suffix of the given number.
Example,
Inputs Outputs
1 st
2 nd
3 rd
11 th
21 st
22 nd
23 rd
4. WAP in C/
C++/ java to divide two integers (dividend and
divisor)
Example,
Dividend = 7
Divisor = 2
Result = 3
Dividend = -17
Divisor = 5
Result = -3
5. WAP in C/
C++/ java to generate prime numbers between M and N ( 0> M,N
<1000 )
6. WAP in C/ C++/ java to find the factorial of the number.
Factorial : 3! = 1 x 2 x 3 = 6
4! = 1 x 2 x 3 x 4 = 24
7. WAP in C/
C++/ java to find sum of the digits of the number.
Example, Input : 123, Output : 6 [ expl. 1+2+3]
8. WAP in C/
C++/ java to check whether the number is a Neon number or not.
Input : 9
Output :
Neon Number
Explanation: square is 9*9 = 81 and sum of the digits of the square ( 8+1) is 9.
Input :12
Output :
Not a Neon Number
Explanation:
square is 12*12 = 144 and sum of the digits of the square is 9 (1 + 4 + 4)
which is not equal to 12.
9.
WAP
in C/ C++/ java to check whether the number is a Special Number or not.
Definition : If the sum of the factorial of digits of a
number (N) is equal to the number itself, the number (N) is called a special number.
INPUT : 145 The digits of the number are: 1, 4, 5
Factorial of digits:
!1 = 1
!4 = 4*3*2*1 = 24
!5 = 5*4*3*2*1 = 120
Sum of factorial of digits = 1 + 24 +
120 = 145
Hence, the given number 145 is a special number.
10. WAP in C/ C++/ java to check whether a number is a Harshad Number or not.
In recreational mathematics, a Harshad number in a given number base is an
integer that is divisible by the sum of its digits when written in that base.
Example: Number 200 is a Harshad Number because the sum of digits 2 and 0 and 0
is 2(2+0+0) and 200 is divisible by 2. Number 171 is a Harshad Number because
the sum of digits 1 and 7 and 1 is 9(1+7+1) and 171 is divisible by 9.
Input a number : 353
Expected Output : 353 is not a Harshad Number.
Comments
Post a Comment