0% found this document useful (0 votes)
19 views24 pages

Manjunadh Ece 27

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views24 pages

Manjunadh Ece 27

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Problem Solving

and
Algorithm
Thinking
23ECE102
ASSIGNMENT -
1

Submitted BY:
Name: Y . manjunadh
Branch: ECE(AVVP)
1st YEAR
Roll no: NC.EN.U4ECE24027

Program 1:
Design pseudo code /program that ask
the user to enter an object’s mass, and
then calculates its weight. If the object
weighs more than 1,000 Newtons,
display a message indicating that it is
too heavy. If the object weighs less
than10 Newtons, display a message
indicating that it is too light. Write the
algorithm, flowchart and pseudo code
for above

ALGORITHM:

Step 1: start
Step 2: declare the varible mass and
weight
Step 3: print the input of mass
Step 4: calculate weight by using assign
weight=mass *9.8
Step 5: declare the if statement and
give condition weight is greater than
1000
if condition is true that display
the output and print “the weight too
heavy”
else
step 6: by using if statement give the
condition weight is greater than 10
if the condition is true give the
output “ the weight is too light ”
Step 9: stop

FLOW CHART:
PSEUDO CODE:
OUTPUT:

Program 2:
Design a program/ psecudocode that
ask the user to enter a month (in
numericform), a day, and a two-digit
year. The program should then
determine whetherthe month times the
day equals the year. If so, it should
display a message saying the date is
magic. Otherwise, it should display a
message saying the date is not magic.

ALGORITHM:

Step1: start
Step 2: declare the variable date, month
and year
Step 3: print the output that display
“enter the data and month”
Step 4: input date and month
Step 5: print the output to enter the
year
Step 6: input year
Step 7: by using if statement write a
condition year=month *date
If condition is correct it print output the
date is magic
Else
It print output “ the date is not magic”
Step 10: stop
FLOW CHART:

Pseudo code:
OUTPUT:
Program 3:
Design a program/ psecudocode that
ask the user to enter the total rainfall for
each month over a 12-month period.
The program should calculate and
display the total rainfall for the year, the
average monthly rainfall, and the month
with the highest and lowest rainfall.
Write the algorithm, flowchart and
pseudo code for above

ALGORITHMIC:
Step 1: start
Step 2: declare the variables total, t,
average, Integer SIZE, large, small
Step 3: assign size 12 Integer Array
numbers [SIZE] Real largest, smallest,
Integer i
Step 4: assign for loop condition I =0 to
size -1
Step 5: assign =number [0], large
=[number]
Step 6: assign
Step 7: assign if block and give the
condition “year = month * data”
Step 8: the is true if will be executed the
true block statement that display “your
birth date is magic”
Step 9: the is false that display that
“your birth date is not magic”
Step 10: end
FLOW CHART:
PSEUDO CODE:
Function Main
Declare Real total, t, average
Declare Integer SIZE
Declare Integer large, small

Assign SIZE = 12
Declare Integer Array numbers [SIZE]
Declare Real largest, smallest
Declare Integer i

For i = 0 to SIZE-1
Output "Enter the rainfall of the
month "&(i+1) &" in cm:"
Input numbers [i]
End
Assign largest = numbers [0]
Assign large = 0
Assign smallest = numbers [0]
Assign small = 0
For i = 0 to SIZE-1
If numbers [i]>largest
Assign largest = numbers [i]
Assign large = i
End
End
For i = 0 to SIZE-1
If numbers[i]<smallest
Assign smallest = numbers [i]
Assign small = i
End
End
Assign total = 0
For i = 0 to SIZE-1
Assign t = total + numbers [i]
Assign total = t
End
Output "Total rainfall of the year: "&
total & "cm"
Assign average= total/12
Output "Average monthly rainfall:
"&average &"cm"
Output "Highest rainfall of the year is
month "&(1+large) &" with the rainfall
of "&largest &"cm"
Output "Lowest rainfall of the year is
month "&(1+small) &" with the rainfall
of "&smallest &"cm"
End

OUTPUT:

Program 4:
Design a program/ pseudo code that ask
the user to input how many litre’ s of
water they drank each day for a week.
The program should calculate and
display the average daily water intake. If
the average is less than 2 litre’ s,
display "You should drink more water!"
otherwise display "Great hydration!"
Write the algorithm, flowchart and
pseudo code for above.

ALGORITHM:

Step 1: start
Step 2: declare the variable 1 to 7 and
average
Step 3: give the output “enter the daily
water intake from Monday to Sunday in
liters”
Step 4: print the input 1 to 7
Step 5: assign the average add the total
number (1 to 7) and divided by 7
Step 6: by using if statement write a
condition average <2
If the condition is correct it print output
“the average water intake” and display
the statement “you should drink more
water”
else
if the condition is false it print output
“the average water intake” and display
the statement “Great hydration”
Step 9: stop

FLOW CHART:
OUTPUT:

Program 5:
Given the nested if-else below, what will
be the value x when the code executed
successfully.
x=0
a=7
b=5
if a>0:
if b<0:
x=x+5
elif a>5:
x=x+4
else:
x=x+3
else:
x=x+2
print(x)

ALGORITHMIC:

Step 1: start
Step 2: declare the integer x=, a=, b=
Step 3: give the value x for 0 and a for 7
and b for 5
Step 4: assign if block and give the
condition a>0 then the condition is false
execute the condition x=x+2
Step 5: the condition is true execute the
condition b<0
Step 6: the condition is true then
execute x=x+5
Step 7: the condition is false the
condition execute the condition x=x+4
Step 8: the is false execute the
condition x=x+3
Step 9: end
INPUT :

OUTPUT:
PPSEUCODE:

You might also like