Wednesday, March 1, 2017

C++ Program.Write a program to display area of square.





#include<stdio.h>
#include<conio.h>
void main()
{float side,area;
clrscr();
printf("\nEnter value of side");
scanf("\n%f",&side);
area=side*side;
printf("\n%f",area);
getch();
}

C++ Program. Write a program to display area of triangle.



#include<stdio.h>
#include<conio.h>
void main()
{float base,height,area;
clrscr();
printf("\nEnter value of base");
scanf("\n%f",&base);
printf("\nEnter value of height");
scanf("\n%f",&height);
area=(base*height)/2;
printf("\n%f",area);
getch();
}     

C++ Program .Write a program convert fharenhite to celcius.



#include<stdio.h>
#include<conio.h>
void main()
{
int fh,cl;
clrscr();
printf("\n enter the value of fh");
scanf("\n %d",&fh);
cl=(fh-32)/1.8;
printf("\n convert celcius %d",cl);
getch();
}

C++ Program .Write a program to display simple intress.

#include<stdio.h>
#include<conio.h>
void main()
{
float p,n,r,si;
clrscr();
printf("\n enter the value of p");
scanf("\n %f",&p);
printf("\n enter the value of n");
scanf("\n %f",&n);
printf("\n enter the value of r");
scanf("\n %f",&r);
si=(p*n*r)/100;
printf("\n %f",si);
getch();
}

C++ Program .Write a program to input an integer number & check it’s prime number or not using if....else.

#include<stdio.h>
#include<conio.h>
void main()
{
int num,i;
clrscr();
printf("\n enter the value of num");
scanf("\n %d",&num);
for(i=2;i<num;i++)
{
if(num%i==0)
  {
   break;
  }
}
if(num==i)
  {
  printf("\n number is prime");
  }
else
{
printf("\n number is not prime");
}
getch();
}