Write A Program To Find The Area of Circle
Write A Program To Find The Area of Circle
-
6563
1. Write a program to find the Area of circle
#include<iostream.h>
#include<conio.h>
#define PI 3.1427
Int main ()
{
clrscr();
float ra;
cout<<!"n #nter the radius of the $ircle % !;
cin>>r;
a&PI'r'r;
cout<<!"n (rea of the $irle is % )<<a<<! units!;
*etch();
return 1;
+
Output is :
#nter the radius of $ircle % 4
(rea of the $ircle is % ,-.2.32 units
2. Write a program to find the Average of two numbers.
Soft. Lab -1 M. Tech. (Part Time) Roll No.-
6563
#include<iostream.h>
#include<conio.h>
Int main ()
{
clrscr();
float a/c&-;
cout<<! #nter the 0alues of t1o num/ers.!<<! "n 2alue of a &!;
cin>>a;
cout<<!"n 2alue of /&!;
cin>>/;
c&(a3/)42;
cout<<!"n (0era*e of t1o num/ers is & )<<c;
*etch();
return 1;
+
Output is :
#nter the 0alues of t1o num/ers.
2alue of a & 1,
2alue of / & 17
(0erra*e of t1o num/ers is & 15
3. Write a program to swap two numbers.
Soft. Lab -1 M. Tech. (Part Time) Roll No.-
6563
#include<iostream.h>
#include<conio.h>
Int main ()
{
clrscr();
int a/;
cout<<! #nter the 0alues of t1o num/ers.!<<! "n 2alue of a &!;
cin>>a;
cout<<!"n 2alue of /&!;
cin>>/;
a&a3/;
/&a6/;
a&a6/;
cout<<! "n (fter s1a77in* %6 a& )<<a<<!"n /&!<</;
*etch();
return 1;
+
Output is :
#nter the 0alues of t1o num/ers.
2alue of a & 3
2alue of / & ,
(fter s1a77in* %6 a&,
/&3
4. Write a program to find whether a given number is Even or Odd.
#include<iostream.h>
#include<conio.h>
Soft. Lab -1 M. Tech. (Part Time) Roll No.-
6563
Int main ()
{
clrscr();
int a;
cout <<! #nter an8 9um/er n& !;
cin>>a;
if(a:2&&-)
{
cout<<!"n ;i0en num/er is #0en!;
+
else
{
cout<<! ;i0en num/er is <dd!;
+
*etch();
return 1;
+
Output is :
#nter an8 9um/er n& 5
;i0en num/er is #0en
. Write a program to displa! the first ten "atural number.
#include<iostream.h>
#include<conio.h>
Int main ()
{
Soft. Lab -1 M. Tech. (Part Time) Roll No.-
6563
clrscr();
int a;
cout<<! =he >irst ten natural num/ers are %!;
for(a&1;a<&1-;a33)
{
cout<<a;
+
cout<<!"n!;
*etch();
return 1;
+
Output is :
=he >irst ten natural num/ers are %
1
2
3
4
,
5
7
.
?
1-
#. Write a program to reverse the two digit number.
#include<iostream.h>
#include<conio.h>
Int main ()
{
clrscr();
int a/n;
cout<<!#nter an8 t1o di*it num/er n & );
cin>>n;
a&n41-;
Soft. Lab -1 M. Tech. (Part Time) Roll No.-
6563
/&n:1-;
a&(/'1-)3a;
cout<<!"n (fter re0erse the n is % )<<a;
*etch ();
return 1;
+
Output is :
#nter an8 t1o di*it num/er n & ,4
(fter re0erse the n is % 4,
$. Write a program ma%e structure li%e given :
1
12
123
1234
#include<iostream.h>
#include<conio.h>
Int main ()
{
clrscr();
Soft. Lab -1 M. Tech. (Part Time) Roll No.-
6563
int i@n;
cout<< )#nter an8 num/er u7to 1hich structure is to made n& !;
cin>>n;
for(i&1;i<&n;i33)
{
for(@&1;@<&I;@33)
{
cout<<@;
+
cout<<!"n!;
+
*etch ();
return 1;
+
Output is :
#nter an8 num/er u7to 1hich structure is to made n & ,
1
12
123
1234
1234,