0% found this document useful (0 votes)
50 views2 pages

4 - Looping Statements

This document provides a list of 10 programming problems for a C programming lab. The problems involve writing code to check if a number is odd or even, convert temperatures between Celsius and Fahrenheit/Kelvin scales, calculate employee net salary based on inputs for designation and city type, print an egg timer pattern based on a user-input size, calculate sums of integers by repeatedly getting user input, and design a basic calculator that allows the user to choose arithmetic operations on two float numbers. The goal is for students to practice using input/output statements, conditional and looping statements in C code.

Uploaded by

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

4 - Looping Statements

This document provides a list of 10 programming problems for a C programming lab. The problems involve writing code to check if a number is odd or even, convert temperatures between Celsius and Fahrenheit/Kelvin scales, calculate employee net salary based on inputs for designation and city type, print an egg timer pattern based on a user-input size, calculate sums of integers by repeatedly getting user input, and design a basic calculator that allows the user to choose arithmetic operations on two float numbers. The goal is for students to practice using input/output statements, conditional and looping statements in C code.

Uploaded by

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

Shiv Nadar University, Chennai

DEPARTMENT OF CSE - Research

PROGRAMMING IN C LABORATORY
4 : C Programs using I/O statements, conditional and looping statements
===========================================================
Learning Outcome :
To be proficient in basic features of C
- using I/O statements (getchar/putchar, scanf/printf)
- operators and expressions (arithmetic / unary / conditional / relational / logical )
- conditional constructs ( if / nested if, switch)
- looping constructs (for, while, do-while)
To learn to develop code incrementally

Write the algorithm to solve the following problems and implement them in C.

1) Check whether the given integer is odd or even


2) Convert the given temperature in Celsius to Fahrenheit and Kelvin scale.
3) Modify (1) to set a flag to 1 if number is odd; 0 if even (Use conditional operator)
4) Find the net salary of an employee by getting the basic pay (BP) as input. Compute the
net pay based upon the following formulae:
DA = 88% of BP
HRA = 8% of BP
CCA = Rs. 1000
Insurance = Rs. 2000
PF = 10% of BP
Gross Pay = BP + DA + HRA + CCA
Deductions = Insurance + PF
Net Pay = Gross Pay – Deductions
5) Modify (4) to set HRA based on type city which is input (Metro (M) 10%; Corporation (C)
8%; Taluk (T) 5%); to set CCA based on designation (Worker (W) 1000; Engineer (E)
2000; Manager (M) 5000) (Use case / nested if)
6) Write a C program that will ask the user for a whole number N between 3 and 10 and print
an egg timer of size N. Validate N to be non-zero positive number.

Example
Enter a number ? 4
*-*-*-*
*-*-*
*-*
*
*-*
*-*-*
*-*-*-*
7) Write a program that computes sum of N integers (Version 1)
a. Get input for N, multiple times until -999 is given (Version 2) (Use do-
while)
b. Get input for N, multiple times until ‘STOP’ is given (Version 3)
c. Validate N to be a positive number less than 100. (Version 4)
d. Print error message for invalid input and exit (Version 5) (Use break)
e. If input is invalid, print message and ask for another input. (Version 6)
8) Design a calculator to perform the operations namely addition, subtraction, multiplication,
division and square of a number. (Hint: Provide operation options for the user to choose,
after getting two numbers of type float) (Use case)
9) Write a C program to check if a number has three consecutive 5s. If yes, print YES, else
print NO.
Example
Number: 1353554
Result: NO
Number: 345559
Result: YES
10) Implement the solution for (1) without a condition.

*******************

You might also like