0% found this document useful (0 votes)
58 views3 pages

Topic: Problems Based On General Mathematical Calculations:: S A B C Area Ss As Bs C 2

The document provides instructions for a lab assignment to write programs to solve various mathematical problems. The problems include calculating simple interest and amounts, finding sums and averages, determining surface areas and volumes of shapes, converting between temperature scales, solving quadratic equations, and more. Example problems are provided with algorithms and sample code in C programming language to calculate the area of a triangle given its sides or base and height.

Uploaded by

Sunita Yadav
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)
58 views3 pages

Topic: Problems Based On General Mathematical Calculations:: S A B C Area Ss As Bs C 2

The document provides instructions for a lab assignment to write programs to solve various mathematical problems. The problems include calculating simple interest and amounts, finding sums and averages, determining surface areas and volumes of shapes, converting between temperature scales, solving quadratic equations, and more. Example problems are provided with algorithms and sample code in C programming language to calculate the area of a triangle given its sides or base and height.

Uploaded by

Sunita Yadav
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/ 3

LAB ASSIGNMENT NO 1:

Topic: Problems based on general mathematical calculations:


Write programs to solve following problems.

1. To calculate simple interest and amount based on the supplied principle, rate of interest and time
period.
2. To calculate sum and average of any three different integer values.
3. To calculate total surface area and volume of a cuboid based on its dimensions (l,b and h) given.
[Hint: tsa=2(lb+bh+lh) and volume=lbh]
4. To accept length, breadth, height of a room and rate of painting per sq m in Rs. and calculate and
print out the area of four walls, volume, total cost required for painting the walls.
5. To calculate area of a triangle based on the supplied base and height.
6. To accept three different sides of a triangle and calculate area its area by following the hint given
below:
7. To calculate area of a triangle based on its three sides input by a user.
a+b+c
[hint: s = , area = s( s − a )( s − b )( s − c) where a,b & c are three sides of a
2
triangle.]
8. To accept temperature in CELCIUS and convert it into FAHRENHEIT.
9
i. [HINT: F = C + 32 ] where C – CELCIUS value and F –
5
FAHRENHEIT.
9. To input temperature in FAHRENHEIT and convert it into CELCIUS equivalent.
10. To input the value of coefficient a, b and c of a quadratic equation (ax2+ bx+c=0) and find out the
relative value of x.
− b ± b 2 − 4ac
[Hint: x= ]
2a
11. To input the radius of a sphere and calculate its volume on the basis of the radius. [Hint:
4
V = π r3 ]
3
12. To ask a user for inputting time in second and display it in the format hh:mm:ss converting the
value based on its limit.
13. To ask a user for supplying distance covered by a vehicle in cm and display it in the km, m and
cm converting the value based on its limit.
14. To convert month input by a user into possible number of days.
15. To calculate distance travelled by an object based on its initial velocity, final velocity and the
acceleration.

v2 − u2
s=
[Hint: 2a where s= distance covered by the object, v=final velocity, u=initial velocity,
a= acceleration ]

16. To convert the total number of days given into possible number of month and day.
17. To find the sum of the digits of any four digit number without using loop.
18. To generate reverse value of any four digit number without using loop.
19. To ask user for inputting the price of a stuff in paisa and convert it into the nearest rupees and
paisa.
20. To calculate the total cost required for fixing glass in the four identical square shaped windows
having semi-circular shaped ventilation on the basis of the rate of glass (In Rs./sq ft) and the
length of window (in ft) given by the user.
NOTE: you need to practice developing programs with program designing
tools use so that you could analyse the logics correctly.

Example:

Problem: To calculate area of a triangle based on the supplied base and


height.

Algorithm:
START:
STEP 1: READ base and height as b and h. INPUT
STEP 2: calculate the area of the triangle as area by using the relation such as
Area=1/2*b*h. PROCESSING
STEP 3: Display the area as the area of the triangle calculated. OUTPUT
STOP:

SOURCE CODE IN C:
/* program to calculate area of a triangle based on its base and height given */
#include <stdio.h>
#include <conio.h>
main() //logical beginning of the program
{ //beginning of main function
float b,h,area; //declaration of three real variables
clrscr(); //to clear the screen
/* INPUT PART */
printf("enter the base and height of the triangle:"); //to display message
scanf("%f%f",&b,&h); //to prompt a user for data supply
/* PROCESSING PART */
area=1.0/2.0*b*h; //to calculate area
/* OUTPUT PART */
printf("the area of the triangle is : %.2f",area);

} //end of program

Problem: To calculate area of a triangle based on its three sides input by a user.

a+b+c
[Hint: s= , area = s( s − a )( s − b )( s − c) where a,b & c are three sides of a
2
triangle.]

ALGORITHM:
START:
Step 1: READ the three sides of a triangle given by a user as a,b,c .
Step 2: Calculate s(semiperimeter) and the area of the triangle by using the relation as shown
below:
a+b+c
s= , area = s( s − a )( s − b )( s − c)
2
Step 3: Display the area calculated as the area of the
triangle.
STOP:
In c:
S=(a+b+c)/2.0;
Area=sqrt(s*(s-a)*(s-b)*(s-c))
Where,
sqrt() is a mathematical function which calculates square root value of the given real number.
Syntax: sqrt(real number);

SOURCE CODE IN C:
/* to calculate area of a triangle based on its three sides given */

#include <stdio.h> //pre-processor directive


#include <conio.h>
#include <math.h>
main() //logical beginning of program
{ //beginning of main function
float a,b,c,s,area; //declaration of variables
clrscr(); //to clear the screen;
/*INPUT PART */
printf("enter the three different sides of a triangle :"); //to display the message
scanf("%f%f%f",&a,&b,&c); //to prompt a user to supply the value of a,b and c
/* PROCESSING */
s=(a+b+c)/2.0; //to calculate the value s
area=sqrt(s*(s-a)*(s-b)*(s-b)); //to calculate area
/*OUTPUT PART */
printf("the area of the triangle is : %.2f",area); //to display result
} //end of program

You might also like