0% found this document useful (0 votes)
8 views2 pages

Week2Lab 82823

The document outlines a series of programming tasks for a computing lab. It includes exercises on comparing numbers, determining odd/even status, handling user input for weekdays, calculating student grades based on marks, checking for prime numbers, finding the GCD using the Euclidean algorithm, calculating factorials, and generating Fibonacci sequences. Each task specifies the required input and expected output, along with programming constructs to be used.

Uploaded by

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

Week2Lab 82823

The document outlines a series of programming tasks for a computing lab. It includes exercises on comparing numbers, determining odd/even status, handling user input for weekdays, calculating student grades based on marks, checking for prime numbers, finding the GCD using the Euclidean algorithm, calculating factorials, and generating Fibonacci sequences. Each task specifies the required input and expected output, along with programming constructs to be used.

Uploaded by

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

Fundamentals of Computing

Lab work – week 2


1. Write a program that asks the user to enter 2 numbers and outputs the
greater of the 2 numbers.
2. Write a program that takes a number as input and prints out whether it is
an odd or an even number.
3. Write a program that asks the user to input the current day of the week, if
it’s a weekday the program should print out “Happy weekday! Work
hard!” else the output should be “Enjoy your weekend!”.
4. Write a program that asks the user to enter the name of a student and
marks obtained in any 5 subjects of your choice. The program should
calculate the average marks obtained by the student and assign the overall
grade according to the following criteria:
70 – 100 A
60 – 69 B
50 – 59 C
43 – 49 D
40 – 42 E
0 – 39 F
The output of the program should include the name of the student, the
marks obtained in the 5 subjects, the average marks and the overall grade.
5. Write a program that takes a number as input and prints out whether it is
a prime number or not. (Use while loop)
6. Write a program that takes two numbers as input and finds out the GCD
(greatest common divisor) of the two numbers using the Euclidean
algorithm. (Use while loop)
7. The factorial of a non-negative integer N, denoted by N!, is the product of
all positive integers less than or equal to N.
5! = 5 x 4 x 3 x 2 x 1 = 120
Write a program that takes a non-negative integer N as input and prints
out its factorial. (Use while loop)
8. A Fibonacci sequence is characterized by the fact that every number after
the first two is the sum of the two preceding ones. By definition, the first
two numbers in the Fibonacci sequence are 1 and 1.
1, 1, 2, 3, 5, 8, 13, 21, 34, 55
Write a program that generates the first N numbers of the Fibonacci
sequence and prints them out. N should be taken as input from the user.
((Use for loop)

You might also like