Labels

Showing posts with label Exercise Solving. Show all posts
Showing posts with label Exercise Solving. Show all posts

Thursday, January 26, 2012

Program with Logical Operator

Exercise 16

The marks of five subjects of a particular student is inputted through the keyboard by the user. The division, which the student received will be prompted by the system as per following rules:

Percentage greater than or equal to 60 – First Division

Percentage less than 60 and greater than equal to 50 – Second Division

Percentage less than 50 and greater than equal to 40 – Third Division

Percentage less than 40 – Fail

Solution:
/* Program to find the Division of Marks obtained */
#include<stdio.h>
#include<conio.h>

Sunday, January 15, 2012

Program with Nested if-else statement

Exercise 15

Program to create report card of a student. The user need to enter the marks of English, Science, Maths, Social Studies of an examination out of 100. The program will find the average marks, if the marks is below 35, the system will prompt “Sorry, the student has failed”. If the marks is more than 20 and less than 35, the system will prompt “The student needs little improvement” and if the marks is below 20, then the system will prompt “The student needs to work hard”. If the marks is more than and equal to 35, the system will prompt “The student has passed”. If the marks is greater than or equal to 35 and less than 60 then the system will prompt “Well Done” and if the marks is greater than or equal to 60, then the system will prompt “Excellent”.

Solution:
/* Program to create Report Card of a student */
#include<stdio.h>
#include<conio.h>

Thursday, January 05, 2012

Program with if-else Statement

Exercise 14

Write a program to find the gross salary of individual employee. The conditions to find the gross salary are as follows:

If the basic salary is less than $1500, then HRA is 10% of basic and DA is 90% of basic.

And if the basic salary is more than or equal to $1500, then HRA is $500 and DA is 98% of basic.

The basic salary is inputted through the keyboard by the user.

Solution:
/* Program to find out the gross salary */
#include<stdio.h>
#include<conio.h>

Monday, January 02, 2012

Program with multiple statements within if

Exercise 13
Program to find out the bonus amount of the employees. If the service duration of a particular employee is more than or equal to 3 years then the bonus amount is $2500.00 else the bonus amount is $1000.00.

Solution:

/* Program to calculate the bonus amount of the employee */
#include<stdio.h>
#include<conio.h>

Thursday, April 30, 2009

Program with if statement

Exercise 12
A person purchase certain product from a shop, the shop offers a discount of 10%, if the customer purchases the product of more than $25. If the quantities and price per items are input through the keyboard, write a program to calculate the total expenses.


Solution:



/* Program to calculate the total expense */
#include<stdio.h>
#include<conio.h>

Sunday, April 19, 2009

Program to interchange the last and first digit of a four digit number

Exercise 11

A four digit number is entered through the keyboard and the first and the last digit of the number is interchanged, and the new number so formed will be displayed to the user.

Solution:

#include<stdio.h>
#include<conio.h>

Saturday, April 18, 2009

Program to find the sum of last and first digit of a four digit number

Exercise 10

If a four digit number is input through a keyboard, write a program to obtain the sum of the first and last digit of this number.

Solution:

#include<stdio.h>
#include<conio.h>

Friday, April 17, 2009

Program to reverse the number

Exercise 9
If a five digit number is input through the keyboard, write a program to reverse the number.
Solution:

/* Program to reverse the number of a five digit number */
#include<stdio.h>
#include<conio.h>
#include<math.h>

Thursday, April 16, 2009

Program to sum of the digits of a five digit number.

Exercise 8
If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits.
(Hint: Use the modulus operator ‘%’)
Solution:

/* Program to sum of the digits of a five digit number */
#include<stdio.h>
#include<conio.h>

Wednesday, April 15, 2009

Program to interchange or swap the content of two variables (without the use of third variable)

Exercise 7
Two numbers are inputted through the keyboard into two locations C and D. Write a program to interchange the contents of C and D.(Without the help of 3rd variable)
Solution:

#include<stdio.h>
#include<conio.h>

Tuesday, April 14, 2009

Program to interchange or swap the content of two variables (with the use of third variable)

Exercise 6
Two numbers are inputted through the keyboard into two locations C and D. Write a program to interchange the contents of C and D.(With the help of 3rd variable)
Solution:

#include<stdio.h>
#include<conio.h>

Monday, April 13, 2009

Exercise Solving 5

Exercise 5:
The length and breadth of a rectangle and radius of a circle are input through the keyboard. Write a C program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.
Solution:

#include<stdio.h>
#include<conio.h>

Sunday, April 12, 2009

Exercise Solving 4

Exercise 4:
Temperature of a city in Fahrenheit degree is input through the keyboard. Write a program to convert this temperature into centigrade degree.
Solution:

#include<stdio.h>
#include<conio.h>

Saturday, April 11, 2009

Exercise Solving 3

Exercise 3:
If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and the percentage marks obtained by the student. Assume that the maximum marks obtained by a student in each subject is 100.
Solution:

#include<stdio.h>
#include<conio.h>

Friday, April 10, 2009

Exercise Solving 2

Exercise 2:
The distance between two cities (in Km) is input through the keyboard. Write a program to convert and print the distance in meters, feet, inches and centimeter.
Solution:

#include<stdio.h>
#include<conio.h>

Thursday, April 09, 2009

Exercise Solving 1

Exercise 1:
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 C program to calculate his gross salary.


Solution:

#include<stdio.h>
#include<conio.h>