"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Monday, April 26, 2010

WAP to input dividend and divisor. Calculate quotient and remainder.


#include<iostream.h>
#include<conio.h>
void main()
{
int div, dis, q , r;

cout<< "Enter dividend & divisor :";
cin >> div >> dis;

q = div / dis;
r  = div % dis;

cout << " Quotient = " << q;
cout << "Remainder = " << r;

getch();
}

Write a program to input 3 sides of a triangle and calculate its area.



#include<iostream.h>
#include<conio.h>
#include<math.h>

void main()
{
double s1, s2, s3, ar, s;

cout<< "Enter 3 sides :";
cin >> s1 >> s2 >> s3;
s = (s1+s2+s3)/2;
ar = sqrt( s * ( s - s1) * (s  - s2) * (s - s3));
cout << "\n The Area of the triangle = " << ar;
getch();
}
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.