Intermediate Coding Assignment
Intermediate Coding Assignment
Assignment 2
Question 1:
The loop iterates from 1 to 50. The continue statement skips even numbers, while the break
statement
terminates the loop once the value of i reaches 35. Consequently, only the odd numbers between
1 and 35 will be printed in the output.
Question 2:
C program that continuously prompts the user to enter numbers. It uses a continue statement to
skip processing even numbers and a break statement to exit the loop when a negative number is
entered. Only odd numbers entered by the user are added to the sum.
add 1 to the answer only if c is not divisible by d, else the program goes straight to the print
label using goto statement
Question 4:
Write a C program to implement a simple guessing game. The program should generate a
random number between 1 and 50 (inclusive) and prompt the user to guess the number. After
each guess, the program should provide feedback to the user, indicating whether the guess is too
high, too low, or correct. The user should continue guessing until they correctly identify the
random number. Additionally, limit the number of guesses to 5, and if the user exceeds this limit
without guessing the correct number, display a message indicating that they have lost the game.
Program:
Output:
Question 5:
Write a program that outputs numbers from 1 to n. For multiples of three, output "Fizz"; for
multiples of five, output "Buzz"; and for multiples of both three and five, output "FizzBuzz".
HU22CSEN0300193