First Lecture
First Lecture
First Lecture
COMPUTER PROGRAMMING I
CC 101
Each CPU can have one or more cores. There may be additional kinds of processors, including
GPUs(Graphic processing units) and TPUs(Tensor processing units). Memory itself
is layered (cache memory, main memory, secondary memory). Machines themselves are
networked, giving the appearance of one large machine made up of smaller ones.
Devices are roughly classified into input devices, output
devices and storage devices. Examples include:
A program is a solution developed to solve a particular problem, written in a
form that can be executed on a computer.
Therefore, writing a program is almost the last step in a process that first
determines the problem to be solved and the method to be used in the solution.
Each field of study has its own name for the systematic method of designing
solutions to solve problems.
Note: We can use keyword INPUT or READ or GET to accept input(s) /value(s) and keywords PRINT or
DISPLAY to output the result(s).
The language used to write pseudocode is simple and similar to day-to-day life language. The variable
names are used to store the values. The value store in variable can change in the solution steps.
The statement C = A + B means that add the value stored in variable A and variable B then assign/store
the value in variable C.
The statement R = R + 1 means that add 1 to the value stored in variable R and then assign/store the
new value in variable R, in other words increase the value of variable R by 1
Example Write a pseudocode to convert temperature from Fahrenheit(F) to Celsius (C)
C = 5.0/9.0 (F - 32 )
1. Start
2. Input temperature in Fahrenheit, F
3. Convert temperature in Fahrenheit to temperature in Celsius
C = 5.0/9.0 (F - 32 )
4. Display temperature in Celsius,C
5. Stop
Example Write a pseudocode to find the sum, difference, and product of the two numbers.
1. Start
2. Input the two numbers say Num1,Num2
3. Compute the sum,S , difference,D , and the product,P of the two numbers
S = Num1 + Num2
D = Num1 - Num2
P = Num1 * Num2
4. Print sum S, difference D, and product D
5. Stop
Selection Process
Problems
1. Write a pseudocode to display a word “greater” if the number entered is greater than 10.
2. Write a pseudocode to input two numbers and compare its value and display a message in describing their
comparison.
3. Write a pseudocode to input angle in degree,Deg. Print the message “ The angle is a right angle” if an angle
inputted is equal to 90 degrees, else print the message “The angle is not a right angle.”
4. Write a pseudocode to input a number and display a message “greater than 20” if the number is greater than 20
and also display a word “ODD” or “EVEN” if it is an odd or even number, otherwise “not greater than 20”.
5. Write a pseudocode that assign grade based on the percentage obtained by a student as shown in the table
below
percentage,P grade
P>=90 “A”
75<= P < 90 “B”
65<= P<75 “C”
P below 65 “F”
6. Write a pseudocode to input three numbers and display the lowest number.
1. Write a pseudocode to display a word “greater” if the number entered is greater than 10.
Pseudocode
1. Start
2. Input a number, Num
3. If the number, Num is greater than 10 then If Num > 10
4. Display “ Greater”
5. Endif
6. Stop
2. Write a pseudocode to input two numbers and compare its value and display a message in describing their
comparison.
Pseudocode
1. Start
2. Input two numbers, first number, N1, and second number, N2
3. If N1=N2 then
4. display “Both numbers are equal”
5. Endif
6. If N1>N2 then
7. Display “First number is greater than the second number”
8. Endif
9. If N1<N2 then
10. Display “First number is less than the second number”
11. Endif
12. Stop
3. Write a pseudocode to input angle in degree,Deg. Print the message “ The angle is a right angle” if an angle
inputted is equal to 90 degrees, else print the message “The angle is not a right angle.”
Pseudocode
1. Start
2. Input the value of angle in degree, Deg
3. IF Deg = 90 then
4. Display “The angle is a right angle”
5. Else
6. Display “ The angle is not a right angle”
7. Endif
8. Stop
4. Write a pseudocode to input a number and display a message “greater than 20” if the number is greater than 20
and also display a word “ODD” or “EVEN” if it is an odd or even number, otherwise “not greater than 20”.
Pseudocode
1. Start
2. Input a number, Num
3. IF Num > 20 then
4. Display “ greater than 20”
5. IF NUM%2 =0 the
6. Display “even”
7. else
8. Display “odd”
9. endif
10. Else
11. Display “ not greater than 20”
12. Endif
13. Stop
5. Write a pseudocode that assign grade based on the percentage obtained by a student as shown in the table
below
percentage,P grade
P>=90 “A”
75<= P < 90 “B”
65<= P<75 “C”
P below 65 “F”
Pseudocode
1. Start
2. Input percentage,P
3. If P>=90 then
4. Display “A”
5. Else
6. If P>=75 AND P<90 then
7. Display “B”
8. Else
9. If P>=65 AND P<75 then
10. Display “C”
11. else
12. Display “F”
13. Endif
14. Endif
15. Endif
16. Stop
6. Write a pseudocode to input three numbers and display the lowest number.
Pseudocode
1. Start
2. Input three numbers, N1,N2,N3
3. If N1<N2 then If N1<N2 And N1<N3 then
4. If N1<N3 then Display the lowest, N1
5. Display the lowest, N1 endif
6. Else If N2<N1 And N2<N3 then
7. Display the lowest is, N3 Display the lowest, N2
8. endif endif
9. Else If N3 <N1 And N3<N2 then
10. If N2 < N3 then Display the lowest, N3
11. Display the lowest is , N2 endif
12. else stop
13. Display the lowest is, N3
14. endif
15. Endif
16. stop