Assignment-C Progs

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

ASSIGNMENT

C- Programming

1) Write a program to compute the Square (a*a) and the Cube (a*a*a) for first 10 numbers.

2) Using if-else statement, write a programme where user gets an option to calculate his salary
based on his/her attendance. (E.g. Salary amount has to be user input. Employee gets full
salary with bonus if the attendance is full, for each absentee, Rs 100 is deducted from the
base salary.)

3) Write a program to state if the number entered is odd or even. (Hint: Even numbers are
completely divisible by 2, odd aren’t)

4) Out of 10 students some students are to be admitted to a particular course if the fulfil the
following conditions:

i) Total marks should be greater than 65%.

ii) Height should be greater than 170cms.

Write a program to print the percentage, height and whether or not the student is selected.

5) Write a program to calculate the area of a Triangle, Square, Rectangle and Circle.

The user can choose which shape’s area he/she wants to compute.

(ps: Area of Triangle= base*height*1/2

Area of Square = Side * Side

Area of Rectangle= Length * Breadth

Area of a Circle = PI * Radius * Radius )

6) Write a program to state whether the entered year is a leap year or not.

7) Write a program to calculate the average and marks of a student and give an appropriate grade for the
same.

8) Write a program to calculate the factorial of the entered number.

9) Write a program to calculate the sum of numbers from 1 to 10 using for, while and
do-while loops. Draw flow charts for the same.
10) A university has the following rules for a student to qualify for a degree with A as
the main subject and B as the subsidiary subject:

(i) He should get 55 percent or more in A and 45 percent or more in B.


(ii) If he gets than 55 percent in A he should get 55 percent or more in B. However, he should get
at least 45 percent in A.
(iii) If he gets less than 45 percent in B and 65 percent or more in A he is allowed to reappear in an
examination in B to qualify.
(iv) In all other cases he is declared to have failed.

Write a program to receive marks in A and B and output whether the student has passed, failed or
is allowed to reappear in B.

11) Write a program to find the greatest of the three numbers entered through the keyboard using
conditional operators. Draw a flow chart for the same.

12) A library charges a fine for every book returned late. For first 5 days the fine is 50 paise, for 6-10 days fine is one rupee
and above 10 days fine is 5 rupees. If you return the book after 30 days your membership will be cancelled. Write a
program to accept the number of days the member is late to return the book and display the fine or the appropriate
message.

13) If the three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is valid or not. The
triangle is valid if the sum of two sides is greater than the largest of the three sides.

You might also like