Showing posts with label cplusplus programs. Show all posts
Showing posts with label cplusplus programs. Show all posts
Wednesday, 9 April 2014
write program that inputs divident and divisor.it then calculate and displays the quotient and remainder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include<iostream.h> #include<conio.h> void main(){ int div ,dis, q , r; clrscr(); cout<<enter divident "; cin>>div; cout<<enter divisor "; cin>>dis; q=div/dis; r=div%dis; cout<<"quotient="<<q<<endl; cout<<"remainder="<<r; getch(); } |
OUTPUT
Wednesday, 9 April 2014 by gul ahmad · 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include<iostream.h> #include<conio.h> void main(){ clrscr(); int a,b; int sum; cout<<"Enter any two integers:\n "; cout<<"Enter first integers= "; cin>>a; cout<<"Enter second integers= "; cin>>b; sum = a - (-b); //sum = a - ~b -1; cout<<"Sum of two integers:"<<sum; getch(); } |
OUTPUT
by gul ahmad · 0
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include<iostream.h> #include<conio.h> void main(){ clrscr(); int n; n=1; while(n<=5) { cout<<n<<"\t"<<n*n<<endl; n++; } getch(); } |
OUTPUT
by gul ahmad · 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include<iostream.h> #include<conio.h> void main(){ clrscr(); int n=1,sum=0; while(n<=5) { cout<<n<<endl; sum=sum+n; n=n+1; } cout<<"sum is="<<sum; getch(); } |
OUTPUT
by gul ahmad · 0
1 2 3 4 5 6 7 8 9 10 11 12 |
#include<iostream.h>
#include<conio.h>
void main(){
int n;
n=10;
while(n>=1)
{
cout<<n<<endl;
n=n-1;
}
getch();
}
|
OUTPUT
by gul ahmad · 0
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include<iostream.h> #include<conio.h> void main(){ clrscr(); int n; n=1; while(n<=10) { cout<<n<<endl; n=n+1; } getch(); } |
OUTPUT
by gul ahmad · 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include<iostream.h> #include<conio.h> void main(){ clrscr(); int a,b; cout<<"enter first number="; cin>>a; cout<<"enter second number="; cin>>b; if(a>b) cout<<"first number is greater"; else cout<<"second number is greater"; getch(); } |
OUTPUT
by gul ahmad · 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include<iostream.h> #include<conio.h> void main(){ clrscr(); int n,i; i=1; cout<<"Enter a number : "; cin>>n; while(i<=10) { cout<<n<<"*"<<i<<"="<<n*i<<endl; i=i+1; } getch(); } |
OUTPUT
by gul ahmad · 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include<iostream.h>
#include<conio.h>
void main(){
clrscr();
int pow,num,i=1;
long int sum=1;
cout<<"\nEnter a number: ";
cin>>num;
cout<<"\nEnter power: ";
cin>>pow;
while(i<=pow){
sum=sum*num;
i++;
}
cout<<"the power of number is "<<sum;
getch();
}
|
OUTPUT
by gul ahmad · 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include<iostream.h>
#include<conio.h>
void main(){
clrscr();
int i=1,f=1,num;
cout<<"enter a number=";
cin>>num;
while(i<=num){
f=f*i;
i++;
}
cout<<"factorial of "<<num<<"is"<<f;
getch();
}
|
OUTPUT
by gul ahmad · 0
Tuesday, 8 April 2014
OUTPUT
- #include<iostream.h>
- #include<conio.h>
- void main(){
- int number;
- cout<<"enter any integer:";
- cin>>number;
- if(number % 2 ==0){
- cout<<"the number is even";
- }
- else{
- cout<<"the number is odd";
- }
- getch();
- }
Tuesday, 8 April 2014 by gul ahmad · 0
OUTPUT
- #include<iostream.h>
- #include<conio.h>
- void main(){
- clrscr();
- int num,i,count=0;
- cout<<"enter a number=";
- cin>>num;
- for(i=2;i<=num/2;i++){
- if(num%i==0){
- count++;
- break;
- }}
- if(count==0 && num!= 1){
- cout<<"the number is prime";
- }
- else{
- cout<<"the number is not prime";
- }
- getch();
- }
by gul ahmad · 0
OUTPUT
- #include<iostream.h>
- #include<conio.h>
- void main(){
- clrscr();
- int n,i=1,sum=0;
- cout<<"enter a number=";
- cin>>n;
- while(i<n){
- if(n%i==0)
- sum=sum+i;
- i++;
- }
- if(sum==n){
- cout<<n<<"is perfect number";
- }
- else{
- cout<<n<<"is not perfect number";
- }
- getch();
- }
by gul ahmad · 0
Subscribe to:
Posts (Atom)