[org 0x0100]
; a=b+d
mov ax,[b]
add ax,[d]
mov [a],ax
mov ax,0x4c00
int 0x21
a : dw 0
b : dw 3
d : dw 9
Thursday, 27 September 2018
Tuesday, 3 July 2018
write a programm that prefrom postfix , prefix increment and decrement on a number
Write a program that preform postfix , prefix increment and decrement on a number
///////// solutions
#include <iostream>
using namespace std;
int main() {
int num=10;
cout<<"After the prefix increment"<<++num<<endl;
cout<<"Aftr the postfix increment"<<num++<<endl;
cout<<"After the prefix decrement"<<--num<<endl;
cout<<"Aftr the postfix decrement"<<num--<<endl;
}
a c++ program that preform all the mathematical operation on two numbers
Write a program that preform all the mathematical operation on two numbers that is taken from user
///////// solutions#include <iostream>
using namespace std;
int main() {
int n,m;
cout<<"Enter the First number"<<endl;
cin>>n;
cout<<"Enter the Second number"<<endl;
cin>>m;
cout<<"The sum is "<<n+m<<endl;
cout<<"The sum is "<<n-m<<endl;
cout<<"The sum is "<<n*m<<endl;
cout<<"The sum is "<<n/m<<endl;
cout<<"The sum is "<<n%m<<endl;
}
how to calculate the sum of all the numbers number is taken from the user
Write a program that calculate the sum of all the number that is entered by user
///////// solutions
#include <iostream>
using namespace std;
int main() {
int sum,n;
cout<<"Enter the number plase "<<endl;
cin>>n;
sum=(n*(n+1))/2;
cout<<"The sum is "<<sum<<endl;
}
how to calculat the sum of all number from 1 to 100
Write a program that calculate the sum of all the numbers from 1 to 100
///////// solutions
#include <iostream>
using namespace std;
int main() {
int sum;
sum=(100*101)/2;
cout<<"The sum is "<<sum<<endl;
}
how to convert sec into hour, min,sec in c++
Write a programm that take the time from user in second and
convert it into hour mintue and second
////////// solutions
#include <iostream>
using namespace std;
int main() {
int sec;
cout<<"Enter the time in seconds"<<endl;
cin>>sec;
int hour ,min;
hour=sec/3600;
sec%=3600;
min=sec/60;
sec%=60;
cout<<hour<<" : "<<min<<" : "<<sec<<endl;
project with solution in c++
Write a program that does the following:
a. Prompts the user to input five decimal numbers.
b. Prints the five decimal numbers.
c. Converts each decimal number to the nearest integer.
d. Adds the five integers.
e. Prints the sum and average of the five integers
////////////// Soltion //////////////////
#include <iostream>
using namespace std;
int main() {
//// a part
float a,b,c,d,e;
int sum=0;
cout<<"Enter th score of first number"<<endl;
cin>>a;
cout<<"Enter th score of second number"<<endl;
cin>>b;
cout<<"Enter th score of third number"<<endl;
cin>>c;
cout<<"Enter th score of forth number"<<endl;
cin>>d;
cout<<"Enter th score of fifth number"<<endl;
cin>>e;
// part b
cout<<"first number is "<<a<<endl;
cout<<"second number is "<<b<<endl;
cout<<"third number is "<<c<<endl;
cout<<"forth number is "<<d<<endl;
cout<<"fifth number is "<<e<<endl;
///////////// part c
a=int(a);
b=int(b);
c=int(c);
d=int(d);
e=int(e);
///// part d
sum=a+b+c+d+e;
//////// part e
cout<<"The sum is "<<sum<<endl;
cout<<"The average is "<<sum/5<<endl;
}
a. Prompts the user to input five decimal numbers.
b. Prints the five decimal numbers.
c. Converts each decimal number to the nearest integer.
d. Adds the five integers.
e. Prints the sum and average of the five integers
////////////// Soltion //////////////////
#include <iostream>
using namespace std;
int main() {
//// a part
float a,b,c,d,e;
int sum=0;
cout<<"Enter th score of first number"<<endl;
cin>>a;
cout<<"Enter th score of second number"<<endl;
cin>>b;
cout<<"Enter th score of third number"<<endl;
cin>>c;
cout<<"Enter th score of forth number"<<endl;
cin>>d;
cout<<"Enter th score of fifth number"<<endl;
cin>>e;
// part b
cout<<"first number is "<<a<<endl;
cout<<"second number is "<<b<<endl;
cout<<"third number is "<<c<<endl;
cout<<"forth number is "<<d<<endl;
cout<<"fifth number is "<<e<<endl;
///////////// part c
a=int(a);
b=int(b);
c=int(c);
d=int(d);
e=int(e);
///// part d
sum=a+b+c+d+e;
//////// part e
cout<<"The sum is "<<sum<<endl;
cout<<"The average is "<<sum/5<<endl;
}
c++ simple project of match
Write a program that prompts the user to input five decimal numbers. The
program should then add the five decimal numbers, convert the sum to the
nearest integer, and print the result.
solution :
#include <iostream>
using namespace std;
int main() {
float a,b,c,d,e;
int avg;
cout<<"Enter the score of first match"<<endl;
cin>>a;
cout<<"Enter the score of second match"<<endl;
cin>>b;
cout<<"Enter the score of third match"<<endl;
cin>>c;
cout<<"Enter the score of forth match"<<endl;
cin>>d;
cout<<"Enter the score of fifth match"<<endl;
cin>>e;
avg=(a+b+c+d+e)/(4+1);
cout<<"The average is "<<avg<<endl;
}
c++ full online course problems with solution
Write a program that prompts the user to enter five test scores and then prints
the average test score
/////////solutions:///////////////
#include <iostream>
using namespace std;
int main() {
float a,b,c,d,e;
float avg;
cout<<"Enter the score of first match"<<endl;
cin>>a;
cout<<"Enter the score of second match"<<endl;
cin>>b;
cout<<"Enter the score of third match"<<endl;
cin>>c;
cout<<"Enter the score of forth match"<<endl;
cin>>d;
cout<<"Enter the score of fifth match"<<endl;
cin>>e;
avg=(a+b+c+d+e)/(4+1);
cout<<"The average is "<<avg<<endl;
}
problems with solution in c++
Write a program that produces the following output:
**********************************
* Programming Assignment 1 *
* Computer Programming I *
* Author: ??? *
* Due Date: Thursday, Jan. 24 *
**********************************
**********************************
* Programming Assignment 1 *
* Computer Programming I *
* Author: ??? *
* Due Date: Thursday, Jan. 24 *
**********************************
solution
#include <iostream>
using namespace std;
int main() {
cout<<"**********************************"<<endl;
cout<<"* Programming Assignment 1 * "<<endl;
cout<<"* Computer Programming I *\n"<<endl;
cout<<"* Author: ??? *\n"<<endl;
cout<<"* Due Date: Thursday, Jan. 24 *\n"<<endl;
cout<<"**********************************"<<endl;
}
how to declare character type variable in c++
Write a program that store three values in character type of variables and display
solution
#include <iostream>using namespace std;
int main() {
char a='A', b='D', c='G';
cout<<a<<" "<<b<<" "<<c ;
return 0;
}
how to calculate the sum of floating point number in c++
Write a programm that store three values in floating type of variables and display it sum
solution
#include <iostream>using namespace std;
int main() {
float a=22.33, b=3.44, c= 44.44, sum;
sum =a+b+c;
cout<<"The sum is "<<sum;
return 0;
}
how to calculate the sum of three variables in c++
Write a programm that store three values in integer type of variables and display it sum
solution
#include <iostream>using namespace std;
int main() {
int a=22;
int b=33;
int c= 44;
int sum;
sum =a+b+c;
cout<<"The sum is "<<sum;
return 0;
}
how to declare a variable and assinge value to it
Write a programm that store three values in integer type of variables and display it
solution
#include <iostream>using namespace std;
int main() {
int a=22;
int b=33;
int c= 44;
cout<<a<<"\t"<<b<<"\t"<<c;
return 0;
}
escape sequances in c++
Write a program that print
This is my book
I bought it from
Bilal Book Shop
using single cout statement
solution:
#include <iostream>
using namespace std;
int main() {
cout<<"this is my book \n I bought it from \n Bilal Book shop"<<endl;
return 0;
}
c++ problems with solutions
Write a program that print
This is my book
I bought it from
Bilal Book Shop
solution :
#include <iostream>
using namespace std;
int main() {
cout<<"this is my book"<<endl;
cout<<"I bouth it from "<<endl;
cout<<"bilal book shop"<<endl;
return 0;
}
c++ program that print hello world
wirte a program in that Print Hello World
solution :
#include <iostream>using namespace std;
int main() {
cout<<"Hello World"<<endl;
return 0;
}
Wednesday, 23 May 2018
how to create mirror image of tree in c++
#include<iostream>
#include<cmath>
#include<queue>
using namespace std;
struct tree
{
int num;
tree* left,*right;
}*root;
tree * create(int n)
{
tree *t= new tree;
t->num=n;
t->left=t->right=NULL;
return t;
}
tree * add(tree * r,int nu)
{
if(r==NULL)
{
r= create(nu);
}
else if(nu<=r->num)
{
r->left= add(r->left,nu);
}
else
r->right=add(r->right,nu);
return r;
}
void disply(tree * t)
{
if(t==NULL)
{
return;
}
else
{
cout<<t->num<<" ";
disply(t->left);
disply(t->right);
}
}
tree * deletes(tree * t)
{
while(t->left!=NULL)
{
t=t->left;
}return t;
}
tree * deleteNode(tree * r,int d)
{
if(r==NULL)
{
return r;
}
else if(d<r->num)
{
r->left=deleteNode(r->left,d);
}
else if(d>r->num)
{
r->right=deleteNode(r->right,d);
}
else {
if(r->left==NULL&&r->right==NULL)
{
delete r;
r=NULL;
}
else if(r->right==NULL)
{
tree * temp;
temp=r;
r=r->left;
delete temp;
}
else if(r->left==NULL)
{
tree * temp;
temp=r;
r=r->right;
delete temp;
}
else
{
tree *temp=deletes(r->right);
r->num=temp->num;
r->right=deleteNode(temp,temp->num);
}
}
return r;
}
void printLevelOrder(tree *root) {
if (!root) return;
queue<tree*> nodesQueue;
int nodesInCurrentLevel = 1;
int nodesInNextLevel = 0;
nodesQueue.push(root);
while (!nodesQueue.empty()) {
tree *currNode = nodesQueue.front();
nodesQueue.pop();
nodesInCurrentLevel--;
if (currNode) {
cout << currNode->num << " ";
nodesQueue.push(currNode->left);
nodesQueue.push(currNode->right);
nodesInNextLevel += 2;
}
if (nodesInCurrentLevel == 0) {
cout <<endl;
nodesInCurrentLevel = nodesInNextLevel;
nodesInNextLevel = 0;
}
}
}
void CMI(tree *r)
{
tree*temp,*temp1;
temp=r->left;
r->left=r->right;
r->right=temp;
}
int main()
{
root==NULL;
int n,a,m=1;
while(1){
cout<<"Enter 1 for add\n Enter 2 for display\n Enter 3 for delete node\n Enter 4 for createMirrorImage"<<endl;
cin>>n;
switch(n)
{
case 1:
cout<<"Enter the number for add"<<endl;
cin>>a;
root=add(root,a);
break;
case 2:
printLevelOrder(root);
break;
case 3:
cout<<"Enter the number for delete"<<endl;
cin>>a;
root=deleteNode(root,a);
break;
case 4:
CMI(root);
printLevelOrder(root);
break;
}
}
}
#include<cmath>
#include<queue>
using namespace std;
struct tree
{
int num;
tree* left,*right;
}*root;
tree * create(int n)
{
tree *t= new tree;
t->num=n;
t->left=t->right=NULL;
return t;
}
tree * add(tree * r,int nu)
{
if(r==NULL)
{
r= create(nu);
}
else if(nu<=r->num)
{
r->left= add(r->left,nu);
}
else
r->right=add(r->right,nu);
return r;
}
void disply(tree * t)
{
if(t==NULL)
{
return;
}
else
{
cout<<t->num<<" ";
disply(t->left);
disply(t->right);
}
}
tree * deletes(tree * t)
{
while(t->left!=NULL)
{
t=t->left;
}return t;
}
tree * deleteNode(tree * r,int d)
{
if(r==NULL)
{
return r;
}
else if(d<r->num)
{
r->left=deleteNode(r->left,d);
}
else if(d>r->num)
{
r->right=deleteNode(r->right,d);
}
else {
if(r->left==NULL&&r->right==NULL)
{
delete r;
r=NULL;
}
else if(r->right==NULL)
{
tree * temp;
temp=r;
r=r->left;
delete temp;
}
else if(r->left==NULL)
{
tree * temp;
temp=r;
r=r->right;
delete temp;
}
else
{
tree *temp=deletes(r->right);
r->num=temp->num;
r->right=deleteNode(temp,temp->num);
}
}
return r;
}
void printLevelOrder(tree *root) {
if (!root) return;
queue<tree*> nodesQueue;
int nodesInCurrentLevel = 1;
int nodesInNextLevel = 0;
nodesQueue.push(root);
while (!nodesQueue.empty()) {
tree *currNode = nodesQueue.front();
nodesQueue.pop();
nodesInCurrentLevel--;
if (currNode) {
cout << currNode->num << " ";
nodesQueue.push(currNode->left);
nodesQueue.push(currNode->right);
nodesInNextLevel += 2;
}
if (nodesInCurrentLevel == 0) {
cout <<endl;
nodesInCurrentLevel = nodesInNextLevel;
nodesInNextLevel = 0;
}
}
}
void CMI(tree *r)
{
tree*temp,*temp1;
temp=r->left;
r->left=r->right;
r->right=temp;
}
int main()
{
root==NULL;
int n,a,m=1;
while(1){
cout<<"Enter 1 for add\n Enter 2 for display\n Enter 3 for delete node\n Enter 4 for createMirrorImage"<<endl;
cin>>n;
switch(n)
{
case 1:
cout<<"Enter the number for add"<<endl;
cin>>a;
root=add(root,a);
break;
case 2:
printLevelOrder(root);
break;
case 3:
cout<<"Enter the number for delete"<<endl;
cin>>a;
root=deleteNode(root,a);
break;
case 4:
CMI(root);
printLevelOrder(root);
break;
}
}
}
Wednesday, 16 May 2018
assignment
#include<iostream>
#include<cmath>
using namespace std;
struct tree
{
int num;
tree* left,*right;
}*root;
tree * create(int n)
{
tree *t= new tree;
t->num=n;
t->left=t->right=NULL;
return t;
}
tree * add(tree * r,int nu)
{
if(r==NULL)
{
r= create(nu);
}
else if(nu<=r->num)
{
r->left= add(r->left,nu);
}
else
r->right=add(r->right,nu);
return r;
}
void disply(tree * t)
{
if(t==NULL)
{
return;
}
else
{
cout<<t->num<<" ";
disply(t->left);
disply(t->right);
}
}
tree * deletes(tree * t)
{
while(t->left!=NULL)
{
t=t->left;
}return t;
}
tree * deleteNode(tree * r,int d)
{
if(r==NULL)
{
return r;
}
else if(d<r->num)
{
r->left=deleteNode(r->left,d);
}
else if(d>r->num)
{
r->right=deleteNode(r->right,d);
}
else {
if(r->left==NULL&&r->right==NULL)
{
delete r;
r=NULL;
}
else if(r->right==NULL)
{
tree * temp;
temp=r;
r=r->left;
delete temp;
}
else if(r->left==NULL)
{
tree * temp;
temp=r;
r=r->right;
delete temp;
}
else
{
tree *temp=deletes(r->right);
r->num=temp->num;
r->right=deleteNode(temp,temp->num);
}
}
return r;
}
int main()
{
root==NULL;
int n,a,m=1;
while(1){
cout<<"Enter 1 for add Enter 2 for display Enter 3 for delete node"<<endl;
cin>>n;
switch(n)
{
case 1:
cout<<"Enter the number for add"<<endl;
cin>>a;
for(int i=0;i<=a;i++)
{
if(a==pow(2,i))
{
root=add(root,a);
m=0;
break;
}
}
if (m==0)
{
cout<<"Number is added"<<endl;
m=1;
}
else
cout<<"Number is not added"<<endl;
break;
case 2:
disply(root);
cout<<endl;
break;
case 3:
cout<<"Enter the number for delete"<<endl;
cin>>a;
for(int i=0;i<=a;i++)
{
if(a==pow(2,i))
{
root=deleteNode(root,a);
m=0;
break;}
}
if (m==0)
{
cout<<"Number is deleted"<<endl;
m=1;
}
else
cout<<"Number is not deleted "<<endl;
break;
}
}
}
#include<cmath>
using namespace std;
struct tree
{
int num;
tree* left,*right;
}*root;
tree * create(int n)
{
tree *t= new tree;
t->num=n;
t->left=t->right=NULL;
return t;
}
tree * add(tree * r,int nu)
{
if(r==NULL)
{
r= create(nu);
}
else if(nu<=r->num)
{
r->left= add(r->left,nu);
}
else
r->right=add(r->right,nu);
return r;
}
void disply(tree * t)
{
if(t==NULL)
{
return;
}
else
{
cout<<t->num<<" ";
disply(t->left);
disply(t->right);
}
}
tree * deletes(tree * t)
{
while(t->left!=NULL)
{
t=t->left;
}return t;
}
tree * deleteNode(tree * r,int d)
{
if(r==NULL)
{
return r;
}
else if(d<r->num)
{
r->left=deleteNode(r->left,d);
}
else if(d>r->num)
{
r->right=deleteNode(r->right,d);
}
else {
if(r->left==NULL&&r->right==NULL)
{
delete r;
r=NULL;
}
else if(r->right==NULL)
{
tree * temp;
temp=r;
r=r->left;
delete temp;
}
else if(r->left==NULL)
{
tree * temp;
temp=r;
r=r->right;
delete temp;
}
else
{
tree *temp=deletes(r->right);
r->num=temp->num;
r->right=deleteNode(temp,temp->num);
}
}
return r;
}
int main()
{
root==NULL;
int n,a,m=1;
while(1){
cout<<"Enter 1 for add Enter 2 for display Enter 3 for delete node"<<endl;
cin>>n;
switch(n)
{
case 1:
cout<<"Enter the number for add"<<endl;
cin>>a;
for(int i=0;i<=a;i++)
{
if(a==pow(2,i))
{
root=add(root,a);
m=0;
break;
}
}
if (m==0)
{
cout<<"Number is added"<<endl;
m=1;
}
else
cout<<"Number is not added"<<endl;
break;
case 2:
disply(root);
cout<<endl;
break;
case 3:
cout<<"Enter the number for delete"<<endl;
cin>>a;
for(int i=0;i<=a;i++)
{
if(a==pow(2,i))
{
root=deleteNode(root,a);
m=0;
break;}
}
if (m==0)
{
cout<<"Number is deleted"<<endl;
m=1;
}
else
cout<<"Number is not deleted "<<endl;
break;
}
}
}
Tuesday, 15 May 2018
how to get values from user in c++
#include<iostream>
using namespace std;
int main()
{
int a,b;
cout<<"Enter two number please "<<endl;
cin>>a;
cin>>b;
int sum;
sum=a+b;
cout<<"sum is "<<sum;
}
using namespace std;
int main()
{
int a,b;
cout<<"Enter two number please "<<endl;
cin>>a;
cin>>b;
int sum;
sum=a+b;
cout<<"sum is "<<sum;
}
Subscribe to:
Posts (Atom)