0% found this document useful (0 votes)
21 views10 pages

Lab 2&3

The document provides examples and review questions for a lab on C programming structures, operators, data types, constants, variables, if statements, and if/else statements. The examples include programs to input and calculate values, interchange variable values, print messages, get input and perform calculations, check variable values against thresholds, and calculate grades and electricity bills based on rules. The review questions involve writing programs to print names, calculate areas, perform math operations, and determine even/odd values and speeding status.

Uploaded by

iamisra00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views10 pages

Lab 2&3

The document provides examples and review questions for a lab on C programming structures, operators, data types, constants, variables, if statements, and if/else statements. The examples include programs to input and calculate values, interchange variable values, print messages, get input and perform calculations, check variable values against thresholds, and calculate grades and electricity bills based on rules. The review questions involve writing programs to print names, calculate areas, perform math operations, and determine even/odd values and speeding status.

Uploaded by

iamisra00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Lab no 02

C programming structure, operators, data types, constant and


variables
LAB Exercise Questions
Example 2.1:
Write a program to input length and width in any two variable.

Example 2.2:
Write a program to assign two variables by assignment statement.
Interchange the values and print the result on the screen.
Example 2.3
Write a program to print a message on screen by using “endl” manipulator.

Example 2.4
Write a program in C++ to get two numbers from keyboard during program
execution. Calculate the sum and product of the numbers and then print the
result on the computer.
LAB REVIEW QUESTIONS
Question No1
Write a program in C to print out your name on the output screen

Question No 2
Write the program in C to print the area of circle on the output screen
Question No 3
Write a program in C to add any three numbers and print the result on
output screen.

Question No 4
Write a program in C to get three numbers from user and perform addition
and multiplication.
Question No 5
Write a program in C to assign numeric value to variable year and calculate
the months

LAB No. 03
If statement and If else statement
LAB Exercise Programs
Example 3.1
Write a program to assign value in any variable and check whether it is less
than 20 or not

Example 3.2
Write a program to assign value in to variable ‘a’ and check whether it is
less than 20 or not using if else statement
Example 3.3
Write a program to read three integer numbers then find and print the
largest one among these numbers.

Example 3.4
Write a program that determines a student’s grade. The program will read
three types of scores (quiz, mid-term, and final scores) and determine the
grade based on the following rules: if the average score =90% =>grade=A if
the average score >= 70% and <90% => grade=B if the average score>=50%
and <70% =>grade=C if the average score<50% =>grade=F
Example 3.5
Write a program that prompts the user for the current year, the user's
current age, and another year. It then calculates the age that the user was or
will be in the second year entered

Example 3.6
Write a program to executes a single statement if the given condition is true
Example 3.7
Write a program to calculate the electricity bill. The rates of electricity per
unit are as follow If the units consumed are equal or less than 300, then the
cost is Rs 3/ per unit If units consumed are more than 300, then the cost is
Rs. 3.5/- per unit and a surcharge of 5% of bill is added.

LAB REVIEW QUESTIONS


Question 1
Write a program to determine whether the entered number is even or odd
Question 2
Write a program to determine the following If speed is >65 the car is going
fast generate a message to slow down If speed is <65 generate a message that
you are going on a good pace

You might also like