1. Write a program to compute the simple intrest ?
#include<stdio.h>
#include<conio.h>
void main()
{
int p,r,t,s;
clrscr();
printf("enter principle:\n");
scanf("%d",&p);
printf("enter rate:\n");
scanf("%d",&r);
printf("enter time:\n");
scanf("%d",&t);
s=(p*r*t)/100;
printf("s.i=%d",s);
getch();
}
2. Write a program(WAP) to find sum of any two numbers?
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter first number:\n");
scanf("%d",&a);
printf("Enter second number:\n");
scanf("%d",&b);
c=a+b;
printf("sum=%d",c);
getch();
}
3.WAP to calculate area of rectangle.
#include<stdio.h>
#include<conio.h>
void main()
{
int l,b,A;
clrscr();
printf("Enter length:\n");
scanf("%d",&l);
printf("Enter bredth:\n");
scanf("%d",&b);
A=l*b;
printf("Area of rectangle=%d",A);
getch();
}
4.WAP to calculate Area of triangle by heros formula?
#include<math.h>
#include<conio.h>
#include<stdio.h>
void main()
{
int a,b,c,s,Area;
clrscr();
printf("Enter sides a:\n");
scanf("%d",&a);
printf("Enter sides b:\n");
scanf("%d",&b);
printf("Enter sides c:\n");
scanf("%d",&c);
s=(a+b+c)/2;
Area=sqr[s*(s-a)*(s-b)*(s-c)];
printf("Area of triangle=%d",Area);
getch();
}
5.WAP to enter value of two number and swap the valu.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter first number:\n");
scanf("%d",&a);
printf("Enter second number:\n");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("Enter the value of a=%d",a);
printf("Enter the value of b=%d",b);
getch();
}
6.WAP a program to Enter two number and swaps the value without using third variables?
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter first number:\n");
scanf("%d",&a);
printf("Enter second number:\n");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("The value of a=%d",a);
printf("The value of b=%d",b);
getch();
}
No comments:
Post a Comment