1-This program calculates the square root of the entry number:
#include <iostream.h>
#include <math.h>
#include <conio.h>
void main ( )
{
float num, ans;
cout << " Enter a number: ";
cin >> num;
ans = sqrt(num) ;
cout << " square root is: " << ans << endl;
getch ();
}
2-This program is to demonstrate the increasing and decreasing:
#include <iostream.h>
#include <conio.h>
void main ()
{
int x = 10;
cout << " x = " << x << endl;
cout << "\n ++x = " << ++x << endl;
cout << " x++ = " << x++ << endl;
cout << "\n x = " << x << endl ;
cout << "\n --x = " << --x << endl;
cout << " x-- = " << x-- << endl;
cout << "\n x = " << x << endl ;
getch ();
}
#include <iostream.h>
#include <math.h>
#include <conio.h>
void main ()
{
int x, y, P ;
cout << " Enter a number: " ;
cin >> x ;
cout << " Enter a power : " ;
cin >> y ;
P = pow (x,y) ;
cout << " The result is : " << P << endl ;
getch ();
}
4-This program checks if the numbers were greater than 100
#include <iostream.h>
#include <conio.h>
void main ()
{
int x ;
L: cout << " Enter a number: ";
cin >> x;
if (x > 100)
cout << " Number is greater than 100\n";
else
cout << " Number is less than than 100\n";
goto L;
getch ();
}
5-This program checks whether the entered numbers even numbers or odd
#include <iostream.h>
#include <conio.h>
void main ()
{
int x, y;
L: cout << "\n Enter a number: " ;
cin >> x;
y=x%2;
if (y==0)
cout << " The number is even\n" << endl;
else
cout << " The number is odd\n" << endl;
goto L;
getch ();
}
0 comments:
Post a Comment