Intermediate Coding Assignment
Intermediate Coding Assignment
Assignment 2
Question 1:
The code classifies the entered temperature into different categories based on the range using if-
else control statement range=less than 0 (It's freezing cold), range=0 t0 20(It's a bit chilly),
range=20 t0 30(It's a pleasant day), above 30 (It's quite warm)
Program:
Output:
Question 2:
If the score is valid, the nested if statements determine the grade: 90-100: Grade A, 80-89: Grade
B, 70-79: Grade C, 60-69: Grade D, 0-59: Grade F, If the score is outside the valid range, the
program outputs an error message.
Program:
Output:
Question 3:
Question 4:
user is prompted to enter a password, and they are repeatedly asked until they enter the correct
password using do while
Program:
Output:
Question 5:
print the multiplication table of a number up to a specified range using for loop.
Question 6:
#include <stdio.h>
int main() {
int a=0,b=1,c=2,d;
d=++a || b++ && c++ && a++;
printf("%d %d %d %d",a,b,c,d);
return 0;
}
output:
Question 7:
Using the ternary operator to find the largest of three numbers in C.
Program & Output:
Assignment by
- M. Sai Dinesh
HU22CSEN0300193