Custom Search

Friday, 3 August 2012

WAP program to find area of the rectangle, Write a C or C++ program to find area of the rectangle with output


WAP program to find area of the rectangle, Write a C or C++ program to find area of the rectangle with output



Program
#include<math.h>
#include<stdio.h>
#include<conio.h>
void main()
{
float a,b,c;
clrscr();
printf("Enter the value of the length & breadth of rectangle");
scanf ("%f  %f", &a, &b);
c=a*b
printf("area is");
printf("%f", c);
getch();
}

Changes for C++
If you want to write the same program in c++ apply the following changes to the program.
1.) change the header file from "#include<stdio.h>" to "#include<iostream>.h" 
2.)  for input & output use "cout<<" & "cin>>" instead of "printf" & "scanf".
3.) don't use "% "symbol and "&" sign in "cin>>" statement.


Click here to check the output

No comments:

Post a Comment

Laptops