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

EX:NO:3

DATE:

AIM:
To understand the programming knowledge using Decision Statements (if, if-else, if-
else-if ladder, switch and GOTO)

PROGRAM:

Write a program to print whether a given number is even or odd.

ALGORITHM:

Step 1:start
Step 2: enter a number
Step 3: if (number%2==0)
Print even number else print odd number
Step 4: print the result
Step 5: stop

CODE:

OUTPUT:
EX:NO:3(A)
DATE:

PROGRAM:Write a Program to Check Whether a Number is Prime or not.

ALGORITHM:
Step 1: start
Step 2: get inputs
Step 3:if (n%i==0);
Step 4: print prime number else print not a prime number
Step 5: stop

CODE:

OUTPUT:
EX:NO:3(B)
DATE:

PROGRAM:
Write a program to find the largest and smallest among three entered numbers and
also display whether the identified largest/smallest number is even or odd.

ALGORITHM:
Step 1: start
Step 2: get inputs
Step 3: check the largest and smallest number and see if they are even or odd
Step 4: stop

CODE:

OUTPUT:
EX:NO:3(C)
DATE:

PROGRAM:
Write a program to compute grade of students using if else adder. The grades areassigned as followed:
a. Marks Grade
b. marks<50 F
c. 50≤marks< 60 C
d. 60≤marks<70 B
e. 70≤marks<80 B+
f. 80≤marks<90 A
g. 90≤mars≤ 100 A+

ALGORITHM:
Step 1:start
Step 2: get the marks
Step 3: grade the marks
Step 4:print the result
Step 5:stop

CODE:

OUTPUT:
EX:NO:3(D)
DATE:

PROGRAM:

Write a program to check whether the entered year is leap year or not (a year is leap if it is divisible
by 4 and divisible by 100 or 400.)

ALGORITHM:
Step 1:start
Step 2: get the year
Step 3: check if it is leap year or not
Step 4: print the result
Step 5: stop

CODE:

OUTPUT:
EX:NO:3(E)
DATE:

PROGRAM:
Write a program to find the factorial of a number.

ALGORITHM:
Step 1: start
Step 2: get the number
Step 3: compute factorial *=I
Step 4: print the result
Step 5: stop

CODE:

OUTPUT:
EX:NO:3(F)
DATE:

PROGRAM:
Write a program to check number is Armstrong or not.
(Hint: A number is Armstrong if the sum of cubes of individual digits of a numberis equal to the
number itself).

ALGORITHM:
Step 1: start
Step 2:get the number
Step 3:check if the number is Armstrong or not
Step 4:print the result
Step 5: stop

CODE:

OUTPUT:
EX:NO:3(G)
DATE:

PROGRAM:
Write a program to print day name using switch case.

ALGORITHM:
Step 1:start
Step 2: get a number
Step 3: check the number from the following cases
Step 4: print the result
Step 5:stop

CODE:

OUTPUT:
EX:NO:3(H)
DATE:

PROGRAM:
Write a program to determine whether the input character is capital or small letter, digits
or special symbol.

ALGORITHM:
Step 1: start
Step 2:get a character
Step 3: check if the character is small or capital letter,digit or special symbol
Step 4: print the result
Step 5:stop

CODE:

OUTPUT:
EX:NO:3(I)
DATE:

PROGRAM:
Write a program to check whether a date is valid or not.

ALGORITHM:
Step 1: start
Step 2: get a date
Step 3: check if the date is valid or not
Step 4:print the result
Step 5:stop

CODE:

OUTPUT:
EX:NO:3(J)
DATE:

PROGRAM:
Write a program to check whether a number is positive, negative or zero using switch case.

ALGORITHM:
Step 1:start
Step 2:get a integer
Step 3:check if the integer is positive ,negative or zero from the switch case
Step 4:print the result
Step 5:stop

CODE:

OUTPUT:

RESULT:
Thus from the above programs we learnt the programming knowledge using Decision Statements (if, if-
else, if-else-if ladder, switch and GOTO)

You might also like