Assignment For 2nd Year Computer Science
Assignment For 2nd Year Computer Science
1. Write a program that asks the user to enter a number between 1 and 7 and prints the
corresponding day of the week using a switch statement
2. Write a program that asks the user to input an integer and checks if the number is positive,
negative, or zero using if-else statements. Print the result accordingly.
3. Write a program that reverses a number entered by the user using a while loop.
4. Write a program that checks whether a given year is a leap year or not. A year is a leap year if It
is divisible by 4. But, if it is divisible by 100, it must also be divisible by 400 Use if-else
statements to check this condition.
5. Write a program to print the Fibonacci sequence up to the n-th term, where n is entered by the
user.
6. Write a program that takes an integer as input and determines whether the number is prime or
not using an if-else statement.
7. Write a program that sums all numbers between x and y (inclusive), where x and y are user
inputs. If x is greater than y, print an error message.
BY: BETHELHEM.W