Beruflich Dokumente
Kultur Dokumente
Code:
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int n;
cin>>n;
if(n>0)
cout<<"Positive number";
else
cout<<"Negative number";
getch();
Positive number
Que2. Write a program that accepts a number from user and checks whether it is an odd
number or not.
Code:
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int n;
cin>>n;
if(n%2==0)
cout<<"Number is even";
else
cout<<"Number is odd";
getch();
Number is odd
Code:
//
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int age;
cin>>age;
if(age>=18)
else
getch();
Que4. Write a program that accept x and n from the user. And print the x raise to power n.
Also check whether n is +ve or not.
Code:
//
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
clrscr();
int x,n,ans;
cin>>x;
cin>>n;
if(n>0)
cout<<pow(x,n);
else
cout<<"Power is negative";
getch();
Power is negative
Que5. Write a program to accept principal and time from the user. Find SI accordingly:
Principal Rate
>10000 20%
>7000 15%
>5000 8%
<=5000 5%
Code:
//
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
cin>>p;
cin>>t;
if(p>10000)
r=20;
else if(p>7000)
r=15;
else if(p>5000)
r=8;
else
r=5;
SI=(p*r*t)/100;
getch();