Diwali Assignment Unit-1 20BAI10214
Diwali Assignment Unit-1 20BAI10214
Algorithm
1. Start
2. Input any number ‘n’
3. Check whether n is divisible by 2 or not
4. If yes, then print even
5. Otherwise print odd
6. Stop
Pseudo Code
1. n = get user input
2. r = find remainder of n when divided by 2
3. if r = 0:
a. print even
4. else:
a. print odd
Algorithm
1. Start
2. Set counter for odd number and even number as 0
3. Assign counto = 0 and counte = 0
4. Set N as 1
5. Till N<=10
a. If N divided by 2 is 0, then increase counter for even number by 1
b. Otherwise, increase the counter for odd number by 1
c. Increament n by 1
6. Display counte
7. Stop
Pseudo Code
1. Assign Counto = 0
2. Assign Counte = 0
3. Assign n 1
4. While n<=10
a. If n%2 = 0
i. Counte = counte + 1
b. Otherwise
i. Counto = counto + 1
c. Assign n n + 1
5. Display counte
6. Display counto
#3 Sum of N numbers
Algorithm
1. Start
2. Take input from user in N
3. Set a as 1
4. Set sum as 0
5. Till a<=N
a. Add the a to the sum
b. Increment the value of a by 1
6. Display sum
7. Stop
Pseudo Code
1. N = get user input
2. Assign a = 1
3. Assign sum = 0
4. While a<=N
a. Assign sum = a + sum
b. Assign a = a + 1
5. Display sum
Algorithm
1. Start
2. Take input from user in n
3. If n>0, then display positive
4. If n<0, then display negative
5. Otherwise print 0
6. Stop
Pseudo Code
1. n = get user input
2. If n>0
a. Display positive
3. If n<0
a. Display negative
4. Otherwise
a. Display 0
#5 Find the count of positive and negative numbers
Algorithm
1. Start
2. Set counter for positive number as 0
3. Set counter for negative number as 0
4. Take input from user in a list and store it in ‘lst’
5. for every element in list
a. if element>0, then increment counter for positive number by 1
b. if element<0, then increment counter for negative number by 1
6. print counter for positive number
7. print counter for negative number
8. Stop
Pseudo Code
1. Assign countp 0
2. Assign countn 0
3. Lst = get user input in form of list
4. For every element i in Lst
a. If i > 0
i. Assign countp countp + 1
b. If i < 0
i. Assign countn countn + 1
5. Print countp
6. Print countn
Algorithm
1. Start
2. Assign ‘hello’ in a
3. Set n as 0
4. Till n<6
a. Print a
b. Increment the value of n by 1
5. Stop
Pseudo Code
1. Assign a “Hello”
2. Assign n 0
3. While n < 6
a. Print a
b. Assign n n + 1
#7 Smaller number from given three numbers
Algorithm
1. Start
2. Take input from user and store it in a
3. Take input from user and store it in b
4. Take input from user and store it in c
5. If a<b and a<c, then print a “is the smallest number”
6. If b<a and b<c, then print b “is the smallest number”
7. Otherwise print c “is the smallest number”
8. Stop
Pseudo Code
1. a = get user input
2. b = get user input
3. c = get user input
4. if a < b and a < c
a. print a is the smallest number
5. if b < a and b < c
a. print b is the smallest number
6. else
a. print c is the smallest number
Algorithm
1. Start
2. Take radius as input from user and store it r
22 2
3. Set area as r
7
4. Display area
5. Stop
Pseudo Code
1. r = get user input
22 2
2. Assign area r
7
3. Display area
#9 Find the age validity (Ex. to check valid voter or not, age 18)
Algorithm
1. Start
2. Take input from user and store it in age
3. If age>=18, then print “you can vote”
4. If age<18, then print “you can vote in” 18-age
5. Stop
Pseudo Code
1. age = get user input
2. if age>=18
a. print “you can vote”
3. else
a. print “you can vote in” 18-age “years”
Algorithm
1. Start
2. Print “Enter divisor”
3. Take input from user and store it in a
4. Print “Enter Dividend”
5. Take input from user and store it in n
6. Set Q as n/a
7. Set R as n%a
8. Print Q
9. Print R
10. Stop
Pseudo Code
1. Print “Enter divisor”
2. a = get user input
3. Print “Enter dividend”
4. n = get user input
5. Assign Q n/a
6. Assign R n%a
7. Print Q
8. Print R
#11 Sum of first 100 numbers
Algorithm
1. Start
2. Set sum as 0
3. Set a as 1
4. Till a<=100
a. Add a to the sum
b. Increment the value of a by 1
5. Display sum
6. Stop
Pseudo Code
1. Assign sum 0
2. Assign a 1
3. While a <= 100
a. Assign sum sum + a
b. Assign a a + 1
4. Display sum
Algorithm
1. Start
2. Set sumo as 0 Assign sumo 0
3. Set sume as 0 Assign sume 0
4. Set a as 1
5. Till a<=10
a. If remainder of a when divided by 2 is 0, then
i. Increment the value of sume by 1
b. Otherwise
i. Increment the value of sumo by 1
6. Display sume
7. Display sumo
8. Stop
Pseudo Code
1. Assign sumo 0
2. Assign sume 0
3. Assign a 1
4. While a <=10
a. If a %2 = 0
i. Assign sume sume + 1
b. Otherwise
i. Assign sumo sumo + 1
5. Display sume
6. Display sumo
#13 Find Armstrong number
Algorithm
1. Start
2. Take input from user in n
3. Set sum as 0
4. Set temp as n
5. Till temp > 0
a. Set digit as the remainder of temp when divided by 10
b. Set “sum” as the sum of “sum” and the cube of “digit”
c. Set temp as the quotient when temp is divided by 10
6. If n ==sum, then print n ”is an Armstrong number”
7. Otherwise print n “is not an Armstrong number”
8. Stop
Pseudo Code
1. n = get user input
2. Assign temp n
3. While temp > 0
a. Assign digit temp % 10
b. Assign sum sum + digit3
c. Assign temp temp//10
4. If n==sum
a. Print n, “is an Armstrong number”
5. Else
a. Print n, “is not an Armstrong number”
#14 Sum of digits of a given number
Algorithm
1. Start
2. Take input from user and store it in n
3. Set sum as 0
4. Set temp as n
5. Till temp>0
a. Set digit as the remainder of “temp” divided by 10
b. Set “sum” as the sum of “sum” and “digit” sum sum+ digit
c. Set temp as the quotient of temp when divided by 10
6. Print sum
7. Stop
Pseudo Code
1. n = get user input
2. Assign sum 0
3. Assign temp n
4. While temp > 0
a. Assign digit temp/10
b. Assign sum sum + digit3
c. Assign temp temp//10
5. Print sum
Algorithm
1. Start
2. Take input from user and store it in n
3. Till a<=n
a. Print a
b. Increment the value of a by 1
4. Stop
Pseudo Code
1. n = get user input
2. While a<=n
a. Print a
b. Assign a a + 1
#16 Find and print the multiplication Table (any table, 2,3,..like, 1*2=2,2*2=4....)
Algorithm
1. Start
2. Take input from user and store it in n
3. For every element in range (1,11):
a. Print n ”*” i “=” n*i
4. Stop
Pseudo Code
1. n = get user input
2. For i in range (1,11)
a. Print n “*” i “=” n*i