Professional Documents
Culture Documents
SUBJECT NAME
LIST OF ASSIGNMENTS
Sr. Title of Assignment
No.
GROUP A: Basics needed: printing, scanning, data types,
variables (Any one)
1 On day one of college, two students were interacting with each other. Write a program
to display the communication between them.
2 Consider user as a student and program as professor, write a program for introduction
of a student. Professor is asking following questions:
1. Welcome to First year engineering.
2. What is your name?
3. Tell me your native place.
4. You are staying in a hostel?
5. Tell me your 12th percentage.
6. Tell me your 10th percentage.
Personal Information :
3 Design a program that displays the following information:
1. Your name
2. Your address, with city, state, and ZIP
3. Your telephone number
GROUP B: Basics needed: Operators (Any one)
4 Riya wants to learn basic calculation, help her for following operations by program:
Addition of 2 numbers
1. Subtraction of 2 numbers
2. Division operation of 2 numbers
3. Multiplication of 2 numbers
4. Find the remainder
5. Calculation of percentage
5 Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of
basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate
his gross salary.
6 Distance Traveled :
Assuming there are no accidents or delays, the distance that a car travels down the
interstate can be calculated with the following formula:
Distance = Speed × Time
A car is traveling at 60 miles per hour. Design a program that displays the following:
1. The distance the car will travel in 5 hours
2. The distance the car will travel in 8 hours
3. The distance the car will travel in 12 hours
7 A father said to his son, "I was as old as you are at the present at the time of your
birth". Ask user to enter a father’s age and display the five years back age of son.
GROUP C: Basics needed: Conditions logic (Any two -assignment 12 is
compulsory)
8 Scientists measure an object’s mass in kilograms and its weight in Newtons. If you
know the amount of mass of an object, you can calculate its weight, in Newtons, with
the following formula:
Weight = Mass × 9.8
Design a program that asks the user to enter an object’s mass, and then calculates its
weight. If the object weighs more than 1,000 Newtons, display a message indicating
that it is too heavy. If the object weighs less than 10 Newtons, display a message
indicating that it is too light.
9 Serendipity Booksellers has a book club that awards points to its customers based on
the number of books purchased each month. The points are awarded as follows:
▪ If a customer purchases 0 books, he or she earns 0 points.
▪ If a customer purchases 1 book, he or she earns 5 points.
▪ If a customer purchases 2 books, he or she earns 15 points.
▪ If a customer purchases 3 books, he or she earns 30 points.
▪ If a customer purchases 4 or more books, he or she earns 60 points.
Design a program that asks the user to enter the number of books that he or she has
purchased this month and displays the number of points awarded.
10 Color Mixer :
The colors red, blue, and yellow are known as the primary colors because they cannot
be made by mixing other colors. When you mix two primary colors, you get a
secondary color, as shown here:
▪ When you mix red and blue, you get purple.
▪ When you mix red and yellow, you get orange.
▪ When you mix blue and yellow, you get green.
Design a program that prompts the user to enter the names of two primary colors to
mix. If the user enters anything other than “red,” “blue,” or “yellow,” the program
should display an error message. Otherwise, the program should display the name of
the secondary color that results.
11 Time Calculator :
Design a program that asks the user to enter a number of seconds, and works as
follows:
1. There are 60 seconds in a minute. If the number of seconds entered by
the user is greater than or equal to 60, the program should display the
number of minutes in that many seconds.
2. There are 3,600 seconds in an hour. If the number of seconds entered by
the user is greater than or equal to 3,600, the program should display the
number of hours in that many seconds.
3. There are 86,400 seconds in a day. If the number of seconds entered by
the user is greater than or equal to 86,400, the program should display
the number of days in that many seconds.
12 An Insurance company follows following rules to calculate premium.
1. If a person’s health is excellent and the person is between 25 and 35
years of age and lives in a city and is a male then the premium is Rs. 4
per thousand and his policy amount cannot exceed Rs. 2 lakhs.
2. If a person satisfies all the above conditions except that the sex is
female then the premium is Rs. 3 per thousand and her policy amount
cannot exceed Rs. 1 lakh.
3. If a person’s health is poor and the person is between 25 and 35 years of
age and lives in a village and is a male then the premium is Rs. 6 per
thousand and his policy cannot exceed Rs. 10,000.
4. In all other cases the person is not insured.
Write a program to output whether the person should be insured or not, his/her
premium rate and maximum amount for which he/she can be insured.
Next, she calculates the number of calories that result from the carbohydrates, using
the following formula:
Calories from Carbs = CarbGrams × 4
The nutritionist asks you to design a modular program that will make these
calculations.
20 Fat Gram Calculator :
Design a program that asks for the number of fat grams and calories in a food item.
Validate the input as follows:
▪ Make sure the number of fat grams and calories are not less than 0.
▪ According to nutritional formulas, the number of calories cannot exceed
fatgrams*9. Make sure that the number of calories entered is not greater
than fatgrams*9.
Once correct data has been entered, the program should calculate and display the
percentage of calories that come from fat. Use the following formula:
Percentage of calories from fat = (Fatgrams*9) ÷ Calories
Some nutritionists classify a food as “low fat” if less than 30 percent of its calories
come from fat. If the results of this formula are less than 0.3, the program should
display a message indicating the food is low in fat.
21 Paint Job Estimator :
A painting company has determined that for every 115 square feet of wall space, one
gallon of paint and eight hours of labor will be required. The company charges $20.00
per hour for labor. Design a modular program that asks the user to enter the square
feet of wall space to be painted and the price of the paint per gallon. The program
should display the following data:
1. The number of gallons of paint required
2. The hours of labor required
3. The cost of the paint
4. The labor charges
5. The total cost of the paint job
GROUP G: Basics needed: Use Defined Data Type(Any one)
22 Write a program to store and print the roll no., name, age and marks of a student and
Display it Using Structure.
23 Enter the marks of 5 students in Chemistry, Mathematics and Physics (each out of 100)
named Marks having elements roll no., name, chem_marks, maths_marks and
phy_marks and then display the percentage of each student.
24 Create a structure to specify data of customers in a bank. The data to be stored is:
Account number, Name, Balance in account. Assume maximum of 200 customers in
the bank.
1. Write a function to print the Account number and name of each
customer with balance below Rs. 100.
2. If a customer request for withdrawal or deposit, it is given in the form:
Acct. no, amount, code (1 for deposit, 0 for withdrawal) Write a
program to give a message, “The balance is insufficient for the specified
withdrawal”.
25 An automobile company has serial number for engine parts starting from AA0 to FF9.
The other characteristics of parts to be specified in a structure are: Year of
manufacture, material and quantity manufactured.
1. Specify a structure to store information corresponding to a part.
2. Write a program to retrieve information on parts with serial numbers
between BB1 and CC6.
Text Books:
1. Brian W. Kernighan, Dennis M. Ritchie, “The C Programming Language”, Prentice Hall, ISBN
0131103628, Second Edition.
References:
1. Joyce Farell, “Programming Logic and Design- Comprehensive”, Sixth Edition, Cengage
Learning.
2. Tony Gaddis, “Programming Logic & Design”, Third Edition, Pearson Education.
3. Herbert Schildt, “C – The Complete Reference”, Tata McGraw Hill Publishing Company,Fourth
Edition,New Delhi, 2010.
ASSIGNMENT NO.1
AIM: Consider user as a student and program as professor, write a program for
introduction of a student. Professor is asking following questions:
1. Welcome to First year engineering.
2. What is your name?
3. Tell me your native place.
4. You are staying in a hostel?
5. Tell me your 12th percentage.
6. Tell me your 10th percentage.
PROBLEM DEFINITION :
To understand the basic structure of a C program.
THEORY:
A C program basically consists of the following parts −
Preprocessor Commands
Functions
Variables
Statements & Expressions
The first line of the program #include <stdio.h> is a preprocessor command, which tells a C
compiler to include stdio.h file before going to actual compilation.
The next line int main() is the main function where the program execution begins.
The next line printf(...) is another function available in C which causes the message to be
displayed on the screen.
The next line return 0; terminates the main() function and returns the value 0.
PROBLEM SOLUTION:
Algorithm:
FLOWCHART
FAQs
CONCLUSION: In this assignment, we get to learn about data types, variables, input/output
directives.
ASSIGNMENT NO: 2
These operations are commonly called arithmetic operations. Arithmetic is the oldest and most
elementary branch of mathematics. In this and other related lessons we will briefly explain basic
math operations.
The ones falling into the category of unary arithmetic operators are:
Increment: The ‘++’ operator is used to increment the value of an integer. When placed
before the variable name (also called pre-increment operator), its value is incremented
instantly. For example, ++x. And when it is placed after the variable name (also called post-
increment operator), its value is preserved temporarily until the execution of this statement
and it gets updated before the execution of the next statement. For example, x++.
Decrement: The ‘–‘ operator is used to decrement the value of an integer. When placed
before the variable name (also called pre-decrement operator), its value is decremented
instantly. For example, –x. And when it is placed after the variable name (also called post-
decrement operator), its value is preserved temporarily until the execution of this statement
and it gets updated before the execution of the next statement. For example, x–.
PROBLEM SOLUTION:
ALGORITHM:
FLOWCHART:
CONCLUSION: In this assignment, the concept of selection statement (For Loop) and Branching
Statement (IF/ELSEIF) is used to calculate summation and average of numbers using Mod
Operation.