Conditional Problems Pool
Conditional Problems Pool
Conditional Problems Pool
Conditional Problems
1. 2. 3. 4. 5. 6. 7. Ask the user if he/she has a Quiz tomorrow. If the answer is yes, then display Go and study for the quiz. If the answer is no, then display Go home and watch TV. Input a number form the user, if it is between 1 and 100, display In Range otherwise display Out of Range Write an if-else statement that outputs the word High if the value of the variable score is greater than 100, and Low if the value of score is at most 100. The variable score is of type int. Write a program that gets a number from user, if it is negative then display The number is negative otherwise, display The number is non-negative. Prompt the user for two numbers A & B, computes and displays C=A/B. If the number B is zero, displays a division by Zero message. Write a program that reads an integer and determines and prints whether it is odd or even. (Hint: Use the modulus operator). Write a program that will read an alphabet (a, b, c, , , , z or A, B, C, , , , Z) either in small or big caps. Then the program should display the entered character into its reverse form. For example, if user entered an alphabet in small caps that should be converted and display into its equivalent upper case form and vice versa. Write a program that reads two integers (in any order) and then print either multiple or not according to weather one of the integer is multiple of other. Write a program to input age and print if the age is valid enough to have a NIC card. Prompt the user to enter his/her age. If the age is less than 18 display Too young to vote. If the age is greater than or equal to 18, ask the user if he has ID card? If yes display You can vote otherwise display You cannot vote without ID card Input two positive numbers from user and display the maximum out of them. Write an if-else statement that outputs the word Warning provided that either the value of the variable temperature is greater than or equal to 100, or the value of the variable pressure is greater than or equal to 200, or both. Otherwise, the if-else statement outputs the work OK. The variables temperature and pressure are both of type int. Write a program that reads a character and then prints: It is a vowel if it is a vowel (a, e, i, o, u), It is an operator if it is one of the five arithmetic operators (+, -, /, *, %), and It is something else if it is anything else. Use a switch statement. Write a program that requests an integer value representing the month of the year and gives the number of days in that month. Use Select Case blocks (ignore leap year). Prompts the user to enter a number representing the month of the year. Display the number of days in the month. (The program should work with input like 1 or January, or jaNuaRy as well). Write a program that inputs a day number of the year and prints month and a day of the month. Assume that the year is not a leap year. Three numbers denoted by the variables A, B and C are supplied as input data. Identify and print the largest one of these numbers. Input three positive numbers from user. Compute and display the average of the two highest numbers. Write a program that take three floating point numbers and display them into ascending and descending order. The output should be: Enter number 1: 5 Enter number 2: 7 Enter number 3: 4 The ascending order is: 4 5 7 The descending order is: 7 5 4 Write a program that reads in ten whole numbers using a single cin statement. The user can enter them in any order. Your program should not ask the user to enter the positive and negative numbers separately. Finally the program outputs The sum of the numbers that are greater than zero The sum of the numbers that are less than or equal to zero The sum of all the entered numbers Modify the above program using only 4 variables. A palindrome is a number or a text phrase that reads the same backwards as forwards. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a program that takes input a five digit number from user and determine whether it is a palindrome or not. (e.g., if the user enters 28782, the output of the program should be Its a palindrome. (Hint: use the division and modulus operators to separate the number into its individual digits)
8. 9. 10.
11. 12.
13.
20.
21. 22.
ResourcePerson:ArifButt Page1of3
31. Write a program that reads a single char digit (0-9) and then prints the number as a literal string. For example, if input is 7, then the output should be word seven. Use a switch statement. 32. Write a program that reads two characters and two integers. If the first character or the two characters together form one of the six relational operators (<, >, <=, >=, ==, !=), then two integers are compared using that operator and a message describing the result is printed. Output should be: != 33 77 33 is not equal to 77 33. Write a program that reads a grade, A, B, C, D, E or F and then prints excellent, very good, good, fair, poor, or failure respectively. Use if-else structure Output should be: Enter a grade letter: B good 34. Rewrite the above program using switch statement.
ResourcePerson:ArifButt Page2of3
Subjects
ResourcePerson:ArifButt Page3of3