0% found this document useful (0 votes)
17 views

Here Are 5 Practice Program Questions Based On The Concepts You'Ve Covered (Variables, If-Else, Switch, and While Loop) in C Programming

Uploaded by

Zayed Md
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Here Are 5 Practice Program Questions Based On The Concepts You'Ve Covered (Variables, If-Else, Switch, and While Loop) in C Programming

Uploaded by

Zayed Md
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Here are 5 practice program questions based on the concepts you've covered (variables, if-else,

switch, and while loop) in C programming:

1. Temperature Conversion
Write a program to convert temperature from Celsius to Fahrenheit and vice versa. Use a
variable to store the temperature and an if-else statement to determine which conversion to
perform based on user input (1 for Celsius to Fahrenheit, 2 for Fahrenheit to Celsius).
Formula:

Fahrenheit = (Celsius * 9/5) + 32

Celsius = (Fahrenheit - 32) * 5/9

2. Even or Odd Number


Write a program that takes an integer input from the user and determines if it is even or odd
using an if-else statement.

3. Simple Calculator using Switch Case


Create a program that works as a simple calculator. The program should prompt the user to
enter two numbers and an operator (+, -, *, /). Based on the operator, use a switch case to
perform the appropriate arithmetic operation and display the result.

4. Sum of Natural Numbers Using While Loop


Write a program that takes an integer input from the user and calculates the sum of all natural
numbers up to that number using a while loop.
Example:
Input: 5
Output: Sum = 15 (i.e., 1+2+3+4+5)

5. Number Guessing Game


Create a number guessing game where the program selects a random number between 1 and
100, and the user has to guess the number. Use a while loop to continue prompting the user to
guess until they get it right. After each guess, the program should provide a hint if the number is
too high or too low.

You might also like