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

Week 3

Hh

Uploaded by

uma.kumpatla000
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)
12 views3 pages

Week 3

Hh

Uploaded by

uma.kumpatla000
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

WEEK 3

Simple computational problems using arithmetic expressions.


i) Finding the square root of a given number
ii) Finding compound interest
iii) Area of a triangle using heron’s formulae
iv) Distance travelled by an object

3i) Finding the square root of a given number


PROGRAM:
/* C Program to find the square root of a given number*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main ()
{
int x;
double res;
clrscr();
printf (" Enter any number: ");
scanf (" %d", &x);
res = sqrt(x);
printf (" The square root of %d is: %.2lf", x, res);
getch();
return 0;
}
(Leave 5 lines space for output)
3 ii) Finding compound interest
time
Formula: Compound Interest = Principle * (1 + Rate / 100)

Program:
/* C program to find the Compound Interest */
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main()
{
float p,r,t,ci;
clrscr();
printf("Enter Principle, Rate and Time: ");
scanf("%f%f%f",&p,&r,&t);
ci=p*pow((1+r/100),t);
printf("Compound Interest = %f", ci);
getch();
return 0;
}
(Leave 6 lines space for output)

3iii) Area of a triangle using heron’s formulae


Heron’s Formula:
The area of a triangle when all its sides are given is: sqrt((s) * (s-a) *(s-b) * (s-c))), where s is the
semi perimeter which is equal to (a+b+c)/2, and a, b, c are sides of the triangle.

Program:

/* C Program for finding area of triangle*/


#include <stdio.h>
#include <conio.h>
#include<math.h>
int main()
{
float a, b, c, s, area;
clrscr();
printf("Enter three sides of triangle:");
scanf("%f%f%f",&a,&b,&c);
s = (a+b+c)/2;
area = sqrt(s*(s-a)*(s-b)*(s-c));
printf("Area of triangle = %.2f",area);
getch();
return 0;
}
(Leave 5 lines space for output)
3 iv) Distance travelled by an object

Program:
/* C Program for finding distance travelled by an object*/
#include<stdio.h>
#include <conio.h>
int main()
{
float u,a,d;
int t;
clrscr();
printf("Enter acceleration: ");
scanf("%f",&a);
printf("Enter initial velocity: ");
scanf("%f",&u);
printf("Enter time : ");
scanf("%d",&t);
d = (u * t) + (a * t * t)/2;
printf("The Distance travelled by an object is : %f", d);
getch();
return 0;
}
(Leave 8 lines space for output)

You might also like