Showing posts with label Simple Programs. Show all posts
Showing posts with label Simple Programs. Show all posts

Monday, January 3, 2011

Program to calculate simple interest.

/*
Name: Program to find out Simple interest
Author: Parveen Malik
Date: 03/01/11 18:45
*/

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


void main()
{
float rate,time,prin; // declaring rate, time and principle
float si; // simple interest

printf("Enter the value of\n\nPrinciple : "); // taking user
scanf("%f",&prin); //principle
printf("Rate : ");
scanf("%f",&rate);
printf("Time : ");
scanf("%f",&time);


si=prin*rate*time/100; //formula of finding simple interest
printf("\nSimple Interest : %.2f",si); // printing simple interest to the console

getch();
}




[caption id="attachment_55" align="aligncenter" width="800" caption="OUTPUT:"]program to find out simple interest[/caption]



Program to calculate area of a circle

/*
Name: Program to calculate area of a circle
Author: Parveen Malik
Date: 03/01/11 19:46
*/

#include<stdio.h>
#include<stdio.h>
#define PI 3.141 // to define value of pi


void main()
{
int radius;
float area;

printf("Enter the radius of the Circle : ");
scanf("%d",&radius);

area=PI*radius*radius; // formula to find the area of a circle
printf("\nArea of the Circle is : %.2f",area);

getch();
}
OUTPUT:



[caption id="attachment_12" align="aligncenter" width="656" caption="OUTPUT"]Program to calculate area of a circle[/caption]



Sunday, January 2, 2011

Program to find out sum of any two integers.

/*
Name:  Program to find out sum of any two integers.
Author: Parveen Malik
Date: 02/01/11 16:05
*/

#include<stdio.h>
#include<conio.h>   // preprocessor section


void main()
{
int n1,n2,sum; //declare integers

printf("Enter any two integers \n");
scanf("%d%d",&n1,&n2); // for the user input

sum=n1+n2;

printf("\n\n%d + %d = %d",n1,n2,sum); // to print the sum


getch();
}
 

[caption id="attachment_11" align="aligncenter" width="655" caption="OUTPUT"]Program to find out sum of any two integers.[/caption]