Exercises - 3 - Control Flow

Write a program to find whether person is eligible to vote or not.

Input: age

Output:

Elligible for Vote

Not Elligible for Vote


Write a program to find a number whether it is Positive or negative

Input: number

Output:

Positive

Negative

Neither Positive or Negative


Write a program to find whether the number is divisible by 5

Input: number

Output:

Divisible

Not Divisible


Write a program to find a number whether it is odd or even. Zero is neither odd or even

Input: number

Output:

Even

Odd

Zero is neither odd or even


Find Student result based on total marks

Input: Total Marks

Output:

  1. Print “Pass” if student got 35 marks or more than 35 marks

  2. Otherwise print “Fail”


Print Day Names for the given number

Input: number

Output:

  1. If given number is 1, print "Monday"

  2. If given number is 2, print "Tuesday"

  3. If given number is 3, print "Wednesday"

  4. If given number is 4, print "Thursday"

  5. If given number is 5, print "Friday"

  6. If given number is 6, print "Saturday"

  7. If given number is 7, print "Sunday"

  8. Otherwise print, “Given number is invalid”


Give Grades for student based on below condition

Input: Total Marks

Output:

  1. Total Mark is 100, print “A Grade”

  2. Total Mark is above 90 , print “B Grade”

  3. Total Mark is above 70 , print “C Grade”

  4. Total Mark is above 35 , print “D Grade”

  5. Total Mark is below 35 , print “Fail”


Write a program to calculate profit or loss

Input:

  1. Buying Price

  2. Selling Price

Output:

  1. Print “Profit”, if selling price is more than buying price

  2. Print “Loss” , if selling price is less than buying price


Fizz Buzz FizzBuzz

Input: number

Output:

  1. Print “Fizz” If given number is divisible by 3

  2. Print “Buzz” if given number is divisible by 5

  3. Else Print “FizzBuzz”


Leap Year or Not

Input: Year Number

Output:

Conditions for Leap Year

  1. Year should divisible by 4

  2. Year should not be divisible by 100 only 400 is the exception

Example Inputs:

Example 1:

  1. Input: 2022

  2. Output: Not Leap Year

Example 2:

  1. Input: 2020

  2. Output: Leap Year

Example 3:

  1. Input: 1900

  2. Output: Not Leap Year


Last updated