Thursday 1 February 2018

Example (C Language Simple Programs)


1.Write a program to calculate sum of two numbers.


#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int n1,n2,sum;
printf(“enter the value of n1 and n2”);
scanf(“%d%d”,&n1,&n2);
sum=n1+n2;
printf(\n sum=%d”,sum);
getch( );
}

Out put:
enter the value of n1and n2 4
5
sum=9

2.Write a program to find out the area of circle.

#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
float r,aoc;
float pie=3.14;
printf(“enter the radius of a circle”);
scanf(“%f”,&r);
aoc=pie*r*r;
printf(“\n area of circle=%f”,aoc);
getch( );
}

Out put:
enter the radius of a circle 6
area of circle=113.04

3.Write a program to find the maturity value of a principal P due to the rate of compound interest r% using the formula.
Maturity=p(1+r/100)^n


#include<stdio.h>
#include<conio.h>
#include<math.h>
void main( )
{
clrscr( );
float m,p,n,r,v,s;
printf(“enter the value of principal,rate and time”);
scanf(“%f%f%f”,&p,&r,&n);
v=(1+r/100);
s=pow(v,n);
m=p*s;
printf(“\n maturity=%f”,m);
getch( );
}

Output:
enter the value of principal,rate and time
1000
6
3Maturity=1191.015869

Share this

0 Comment to "Example (C Language Simple Programs)"

Post a Comment