TP2 CPP 23 - 24
TP2 CPP 23 - 24
M1 ESE
LAB work 2
Objectives:
1) Practice working with flow control instructions inC++ using:
Conditional execution: if … else
Loops : for loops, while loops and nested loops
Work to do:
The work consists of 10 exercises.
Even or Odd: Write a program that takes an integer as input and determines whether it's
even or odd.
Leap Year Checker: Create a program that checks if a given year is a leap year. Leap
years are divisible by 4 but not divisible by 100, except when they are divisible by 400.
Guess the Number Game: Implement a number-guessing game where the computer
selects a random number between 1 and 100, and the player has to guess it. Provide hints if
the guess is too high or too low.
Factorial Calculator: Write a program that calculates the factorial of a given positive
integer using a loop.
Sum of Digits: Create a program that calculates the sum of the digits of a positive integer.
Multiplication Table: Generate a multiplication table for a given number, from 1 to 10.
Fibonacci Sequence: Write a program to print the first n numbers in the Fibonacci
sequence.
Grade Calculator: Create a program that takes 5 numerical scores as inputs, calculates the
mean value and outputs the corresponding academic distinction/grade:
Menu-Driven Calculator: Design a simple menu-driven calculator that can perform basic
arithmetic operations (addition, subtraction, multiplication, division) based on user input.