[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;
}
how to declare a variable in c++
//A variable is that whose value can be change during the program execution
#include<iostream>
using namespace std;
int main()
{
int a=10;
int b=3;
int sum;
sum=a+b;
cout<<"sum is "<<sum;
}
#include<iostream>
using namespace std;
int main()
{
int a=10;
int b=3;
int sum;
sum=a+b;
cout<<"sum is "<<sum;
}
escape sequences in c++
\n for new line
\t for tab
\t for tab
for new line
#include<iostream>
using namespace std;
int main()
{
cout<<"this is my\n book";
}
for tab
#include<iostream>
using namespace std;
int main()
{
cout<<"this is my\tbook";
}
c++ program that print hello world
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello world";
}
using namespace std;
int main()
{
cout<<"Hello world";
}
Monday, 12 February 2018
java full course
Here you can learn c++ ,java, data structure ,database
A complete project of hospital management etc
Trigger for update in sql server
create trigger updates on stu
for update as begin declare
@id int
declare @Nname nvarchar(49),@Oname nvarchar(49),
@Nage int,@Oage int,@Nsalary int,@Osalary int
,@ides int ,@names nvarchar(49),@ages int,@salarys int,@dates nvarchar(30)
select * into #temptable from inserted
while(exists(select id from #temptable))
begin
select top 1 @id=id,@Nname=name,@Nage=age,@Nsalary=salary from #temptable
select @Oname= name,@Oage=age,@Osalary=salary from deleted
if(@Oname <> @Nname)
set @names=@Nname
if(@Oage <> @Nage)
set @ages=@Nage
if(@Osalary <> @Nsalary)
set @salarys=@Nsalary
set @dates=cast(getdate() as nvarchar(30))
insert into backs values(@id,@names,@ages,@salarys,@dates)
delete from #temptable where id=@id
end
end
Trigger for insert in sql server
create trigger inserts
on srudent
for insert as begin declare
@id int,
@name nvarchar(30),
@gender nvarchar(7),
@age int
select @id= id ,@name=name,@gender = gender,@age=age from inserted
insert into backs values('New id is '+cast(@id as nvarchar(10))+' New name is '+@name+' New gender is '+@gender+' new age is '+cast(@age as nvarchar(10))+' Date is '+cast(getDate() as nvarchar(20)))
end
trigger for delete in sql server
create trigger Deletes
on srudent
for delete as begin declare
@id int,
@name nvarchar(30),
@gender nvarchar(7),
@age int
select @id= id ,@name=name,@gender = gender,@age=age from deleted
insert into backs values('New id is '+cast(@id as nvarchar(10))+' New name is '+@name+' New gender is '+@gender+' new age is '+cast(@age as nvarchar(10))+' Date is '+cast(getDate() as nvarchar(20)))
end
on srudent
for delete as begin declare
@id int,
@name nvarchar(30),
@gender nvarchar(7),
@age int
select @id= id ,@name=name,@gender = gender,@age=age from deleted
insert into backs values('New id is '+cast(@id as nvarchar(10))+' New name is '+@name+' New gender is '+@gender+' new age is '+cast(@age as nvarchar(10))+' Date is '+cast(getDate() as nvarchar(20)))
end
inner join in sql server
create database shop
use shop
create table product(pid int primary key ,
pname nvarchar(30),
pp int,
sp int)
create table category(id int primary key,pname nvarchar(29))
alter table product add cID int foreign key references category(id)
create proc insrt
@id int,
@name nvarchar(10),
@pp int,
@sp int,
@cID int
as begin
insert into product values(@id,@name,@pp,@sp,@cID)
end
exec insrt 10,'i phone',33,332,11
use shop
create table product(pid int primary key ,
pname nvarchar(30),
pp int,
sp int)
create table category(id int primary key,pname nvarchar(29))
alter table product add cID int foreign key references category(id)
create proc insrt
@id int,
@name nvarchar(10),
@pp int,
@sp int,
@cID int
as begin
insert into product values(@id,@name,@pp,@sp,@cID)
end
exec insrt 10,'i phone',33,332,11
update procedure in sql server
/////////////////////////////////**************** Home ***************/////////////////////
import javax.swing.JPanel;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author bilal
*/
public class Home extends javax.swing.JFrame {
/**
* Creates new form Home
*/
public Home() {
super("Home");
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
p4 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
p1 = new javax.swing.JPanel();
jLabel13 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
p2 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
p3 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jToolBar1 = new javax.swing.JToolBar();
jButton4 = new javax.swing.JButton();
jButton13 = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
import javax.swing.JPanel;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author bilal
*/
public class Home extends javax.swing.JFrame {
/**
* Creates new form Home
*/
public Home() {
super("Home");
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
p4 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
p1 = new javax.swing.JPanel();
jLabel13 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
p2 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
p3 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jToolBar1 = new javax.swing.JToolBar();
jButton4 = new javax.swing.JButton();
jButton13 = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
foreign key in sql server
create database shop use shop create table product(pid int primary key ,pname nvarchar(30),pp int,sp int)create table category(id int primary key,pname nvarchar(29))alter table product add cID int foreign key references category(id)
how to print tree in level order c++
#include<iostream>
#include<queue>
using namespace std;
struct tree
{
int num;
tree *left,*right;
}*root;
void levelOrder(tree *r)
{
queue <tree*> q;
q.push(r);
while(!q.empty())
{
tree *d =q.front();
q.pop();
cout<<d->num<<" ";
if(d->left) q.push(d->left);
if(d->right) q.push(d->right);
}
}
tree * create(int n)
{
tree *t = new tree;
t->left=t->right=NULL;
t->num=n;
return t;
}
tree * add(tree *r,int n)
{
if(r==NULL)
{
r=create(n);
}
else if(r->num>n)
{
r->right=add(r->right,n);
}
else
r->left=add(r->left,n);
return r;
}
void display(tree * t)
{
if(t==NULL)
{
return ;
}
else
{
cout<<t->num<<" ";
display(t->left);
display(t->right);
}
}
int main()
{
root =NULL;
int n,t;
while(true)
{
cout<<"Enter 1 for add Enter 2 for diplay "<<endl;
cin>>n;
switch(n)
{
case 1:
cout<<"Enter the number "<<endl;
cin>>t;
root=add(root,t);
break;
case 2:
display(root);
break;
case 3:
levelOrder(root);
break;
}
}}
#include<queue>
using namespace std;
struct tree
{
int num;
tree *left,*right;
}*root;
void levelOrder(tree *r)
{
queue <tree*> q;
q.push(r);
while(!q.empty())
{
tree *d =q.front();
q.pop();
cout<<d->num<<" ";
if(d->left) q.push(d->left);
if(d->right) q.push(d->right);
}
}
tree * create(int n)
{
tree *t = new tree;
t->left=t->right=NULL;
t->num=n;
return t;
}
tree * add(tree *r,int n)
{
if(r==NULL)
{
r=create(n);
}
else if(r->num>n)
{
r->right=add(r->right,n);
}
else
r->left=add(r->left,n);
return r;
}
void display(tree * t)
{
if(t==NULL)
{
return ;
}
else
{
cout<<t->num<<" ";
display(t->left);
display(t->right);
}
}
int main()
{
root =NULL;
int n,t;
while(true)
{
cout<<"Enter 1 for add Enter 2 for diplay "<<endl;
cin>>n;
switch(n)
{
case 1:
cout<<"Enter the number "<<endl;
cin>>t;
root=add(root,t);
break;
case 2:
display(root);
break;
case 3:
levelOrder(root);
break;
}
}}
add show add delete node from tree
#include<iostream>
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;
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;
root=add(root,a);
break;
case 2:
disply(root);
cout<<endl;
break;
case 3:
cout<<"Enter the number for delete"<<endl;
cin>>a;
root=deleteNode(root,a);
break;
}
}
}
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;
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;
root=add(root,a);
break;
case 2:
disply(root);
cout<<endl;
break;
case 3:
cout<<"Enter the number for delete"<<endl;
cin>>a;
root=deleteNode(root,a);
break;
}
}
}
how to create tree and display all its elements
#include<iostream>
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);
}
}
int main()
{
root==NULL;
int n,a;
while(1){
cout<<"Enter 1 for add Enter 2 for display"<<endl;
cin>>n;
switch(n)
{
case 1:
cout<<"Enter the number for add"<<endl;
cin>>a;
root=add(root,a);
break;
case 2:
disply(root);
cout<<endl;
break;
}
}
}
game of death in the circlar link list
THis is a death game all the peoples are atand in a circle and start from 1 1 kill the second 3 kill the 4 and so on
this is circular link list the rmaining person is one
for Example
1 2 3 4
are stand in a circle
1 3 are kill 2 and 4
and then 1 kill the 3
#include<iostream>
using namespace std;
int nums=0;
struct death
{
int num;
death *next;
}*head,*tail;
void addnumber(int num)
{
nums=num;
for(int i=1;i<=num;i++)
{
death *d= new death;
if(head==NULL)
{
d->num=i;
head =tail=d;
tail->next=head;
}
else
{
d->num=i;
tail->next=d;
tail=d;
tail->next=head;
}
}
}
void display()
{
death * temp;
temp =head;
while(temp->next!=head)
{
cout<<temp->num<<" ";
temp=temp->next;
}
cout<<temp->num<<" ";
cout<<endl;
}
void playGame()
{
death * temp,*temp1;
temp =head;
for(int i=0;i<nums;i++)
{
cout<<temp->num<<" ";
temp1= temp->next;
temp->next=temp1->next;
temp=temp->next;
temp1=NULL;
delete temp1;
} cout<<endl;
cout<<"So the remaining number is "<<temp->num<<" ";
}
int main()
{
head=tail=NULL;
int num;
while(1){
cout<<"Enter the number please "<<endl;
cin>>num;
switch(num)
{
case 1:
int num1;
cout<<"Enter the number of persons in this game"<<endl;
cin>>num1;
addnumber(num1);
break;
case 2:
display();
break;
case 3:
playGame();
break;
}}
}
https://getcryptotab.com/900383
this is circular link list the rmaining person is one
for Example
1 2 3 4
are stand in a circle
1 3 are kill 2 and 4
and then 1 kill the 3
#include<iostream>
using namespace std;
int nums=0;
struct death
{
int num;
death *next;
}*head,*tail;
void addnumber(int num)
{
nums=num;
for(int i=1;i<=num;i++)
{
death *d= new death;
if(head==NULL)
{
d->num=i;
head =tail=d;
tail->next=head;
}
else
{
d->num=i;
tail->next=d;
tail=d;
tail->next=head;
}
}
}
void display()
{
death * temp;
temp =head;
while(temp->next!=head)
{
cout<<temp->num<<" ";
temp=temp->next;
}
cout<<temp->num<<" ";
cout<<endl;
}
void playGame()
{
death * temp,*temp1;
temp =head;
for(int i=0;i<nums;i++)
{
cout<<temp->num<<" ";
temp1= temp->next;
temp->next=temp1->next;
temp=temp->next;
temp1=NULL;
delete temp1;
} cout<<endl;
cout<<"So the remaining number is "<<temp->num<<" ";
}
int main()
{
head=tail=NULL;
int num;
while(1){
cout<<"Enter the number please "<<endl;
cin>>num;
switch(num)
{
case 1:
int num1;
cout<<"Enter the number of persons in this game"<<endl;
cin>>num1;
addnumber(num1);
break;
case 2:
display();
break;
case 3:
playGame();
break;
}}
}
https://getcryptotab.com/900383
a program that convert decimal to using recursion
#include <iostream>
using namespace std;
void decToBin(int num, int base);
int main()
{
int decimalNum;
int base;
base = 2;
cout << "Enter number in decimal: ";
cin >> decimalNum;
cout << endl;
cout << "Decimal " << decimalNum << " = ";
decToBin(decimalNum, base);
cout << " binary" << endl;
return 0;
}
void decToBin(int num, int base)
{
if (num > 0)
{
decToBin(num / base, base);
cout << num % base;
}
}
using namespace std;
void decToBin(int num, int base);
int main()
{
int decimalNum;
int base;
base = 2;
cout << "Enter number in decimal: ";
cin >> decimalNum;
cout << endl;
cout << "Decimal " << decimalNum << " = ";
decToBin(decimalNum, base);
cout << " binary" << endl;
return 0;
}
void decToBin(int num, int base)
{
if (num > 0)
{
decToBin(num / base, base);
cout << num % base;
}
}
program that convert decimal number into binary
#include<iostream>
using namespace std;
struct decimal
{
int num;
decimal *next;
}*head;
void convert( int num)
{ decimal * d= new decimal ;
while(num!=0)
{
decimal * d= new decimal ;
d->next=NULL;
if(head==NULL)
{
d->num=num%2;
head=d;
num/=2;
}
else {
d->num=num%2;
d->next=head;
head=d;
num/=2;
}
}}
void display()
{
decimal * temp;
temp=head;
while(temp!=NULL)
{
cout<<temp->num;
temp=temp->next;
}
}
int main()
{ head =NULL;
int num;
cout<<"Enter the number please "<<endl;
cin>>num;
cout<<"The decimal in binary =";
convert(num);
display();
}
using namespace std;
struct decimal
{
int num;
decimal *next;
}*head;
void convert( int num)
{ decimal * d= new decimal ;
while(num!=0)
{
decimal * d= new decimal ;
d->next=NULL;
if(head==NULL)
{
d->num=num%2;
head=d;
num/=2;
}
else {
d->num=num%2;
d->next=head;
head=d;
num/=2;
}
}}
void display()
{
decimal * temp;
temp=head;
while(temp!=NULL)
{
cout<<temp->num;
temp=temp->next;
}
}
int main()
{ head =NULL;
int num;
cout<<"Enter the number please "<<endl;
cin>>num;
cout<<"The decimal in binary =";
convert(num);
display();
}
Honoli tower problem in data structure
#include<iostream>
using namespace std;
void HanoliTower(int numf,string a,string b,string c)
{
if(numf==1)
{
cout<<"Move Plate "<<numf<<" from "<<a<<" to "<<c<<endl;
}
else {
HanoliTower(numf-1,a,c,b);
cout<<"Move Plate "<<numf<<" from "<<a<<" to "<<c<<endl;
HanoliTower(numf-1,b,a,c);
}
}
int main()
{
HanoliTower(3,"Tower 01","Tower 02","Tower 03");
}
using namespace std;
void HanoliTower(int numf,string a,string b,string c)
{
if(numf==1)
{
cout<<"Move Plate "<<numf<<" from "<<a<<" to "<<c<<endl;
}
else {
HanoliTower(numf-1,a,c,b);
cout<<"Move Plate "<<numf<<" from "<<a<<" to "<<c<<endl;
HanoliTower(numf-1,b,a,c);
}
}
int main()
{
HanoliTower(3,"Tower 01","Tower 02","Tower 03");
}
how to sum of numbers using recursion
#include<iostream>
using namespace std;
int sum(int num)
{
if(num==0)
return 0;
else return num+sum(num-1);
}
int main()
{
int n;
cout<<"Enter any number please"<<endl;
cin>>n;
cout<<"factorial is "<<sum(n)<<endl;
}
how to connect java with sqlite database
who to///////////////////******************* Java Connector ***************////////////////////////
import java.sql.*;
import javax.swing.*;
public class connector {
Connection cn=null;
public static Connection connectorBD()
{
try
{
Class.forName("org.sqlite.JDBC");
Connection cn = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\bilal\\Documents\\NetBeansProjects\\HospitalManagementSystem\\HospitalManament.sqlite");//Here you past your address
return cn;
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e);
return null;
}
}
}
Tuesday, 9 January 2018
recursion in data stucture factorial of a number
#include<iostream>
using namespace std;
int fact(int num)
{
if(num==0)
return 1;
else return num*fact(num-1);
}
int main()
{
int n;
cout<<"Enter any number please"<<endl;
cin>>n;
cout<<"factorial is "<<fact(n)<<endl;
}
using namespace std;
int fact(int num)
{
if(num==0)
return 1;
else return num*fact(num-1);
}
int main()
{
int n;
cout<<"Enter any number please"<<endl;
cin>>n;
cout<<"factorial is "<<fact(n)<<endl;
}
data structure
A program that add new node if the all node in the
#include <iostream>
#include<queue>
using namespace std;
struct BTNode{
int data;
BTNode *left;
BTNode *right;
};BTNode *root;
BTNode* getnewNode(int a){
BTNode *n=new BTNode;
if(a % 2==0)
{
cout<<"num is even: not added"<<endl;
}else
{
n->data=a;
}
n->right=NULL;
n->left=NULL;
return n;
}
BTNode* insertNode (BTNode* r,int d){
if(r==NULL)
{
r=getnewNode(d);
}else
{
if( d<=r->data)
{
r->left=insertNode(r->left,d);
}else
{
r->right=insertNode(r->right,d);
}
return r;
}
}
void in_orderdisplay( BTNode* r)
{
if(r==NULL)
{
return;
}
in_orderdisplay(r->left);
cout<<r->data;
in_orderdisplay(r->right);
}
void pre_orderdisplay(BTNode* r)
{
if(r==NULL)
{
return ;
}
cout<<r->data<<endl;
pre_orderdisplay(r->left);
pre_orderdisplay(r->right);
}
void post_orderdisplay(BTNode* r)
{
if(r==NULL)
{
return;
}
post_orderdisplay(r->left);
post_orderdisplay(r->right);
cout<<r->data;
}
void level_orderdisplay(BTNode* r){
if(r==NULL)
{
return;
}
queue<BTNode*> Q;
Q.push(r);
while(!Q.empty())
{
BTNode* temp=Q.front();
cout<<temp->data;
if(temp->left!=NULL)
{
Q.push(temp->left);
}
if( temp->right!=NULL)
{
Q.push(temp->right);
}
Q.pop();
}
}
int main()
{
int choice,a ;
root=NULL;
char ch='y';
while(ch='y')
{
cout<<"enter 1 to add node "<<endl;
cout<<"enter 2 to display"<<endl;
cout<<"enter 3 to inorder dispaly"<<endl;
cout<<"enter 4 to postorder dispaly"<<endl;
cout<<"enter 5 to level wise display"<<endl;
cin>>choice;
switch(choice)
{
case 1:
cout<<"enter value"<<endl;
cin>>a;
root=insertNode(root,a);
break;
case 2:
pre_orderdisplay(root);
break;
case 3:
in_orderdisplay(root);
break;
case 4:
post_orderdisplay(root);
break;
case 5:
level_orderdisplay(root);
break;
default:
break;
}
cout<<"prees y to continue"<<endl;
cout<<"press n to exist"<<endl;
cin>>ch;
}
}
#include <iostream>
#include<queue>
using namespace std;
struct BTNode{
int data;
BTNode *left;
BTNode *right;
};BTNode *root;
BTNode* getnewNode(int a){
BTNode *n=new BTNode;
if(a % 2==0)
{
cout<<"num is even: not added"<<endl;
}else
{
n->data=a;
}
n->right=NULL;
n->left=NULL;
return n;
}
BTNode* insertNode (BTNode* r,int d){
if(r==NULL)
{
r=getnewNode(d);
}else
{
if( d<=r->data)
{
r->left=insertNode(r->left,d);
}else
{
r->right=insertNode(r->right,d);
}
return r;
}
}
void in_orderdisplay( BTNode* r)
{
if(r==NULL)
{
return;
}
in_orderdisplay(r->left);
cout<<r->data;
in_orderdisplay(r->right);
}
void pre_orderdisplay(BTNode* r)
{
if(r==NULL)
{
return ;
}
cout<<r->data<<endl;
pre_orderdisplay(r->left);
pre_orderdisplay(r->right);
}
void post_orderdisplay(BTNode* r)
{
if(r==NULL)
{
return;
}
post_orderdisplay(r->left);
post_orderdisplay(r->right);
cout<<r->data;
}
void level_orderdisplay(BTNode* r){
if(r==NULL)
{
return;
}
queue<BTNode*> Q;
Q.push(r);
while(!Q.empty())
{
BTNode* temp=Q.front();
cout<<temp->data;
if(temp->left!=NULL)
{
Q.push(temp->left);
}
if( temp->right!=NULL)
{
Q.push(temp->right);
}
Q.pop();
}
}
int main()
{
int choice,a ;
root=NULL;
char ch='y';
while(ch='y')
{
cout<<"enter 1 to add node "<<endl;
cout<<"enter 2 to display"<<endl;
cout<<"enter 3 to inorder dispaly"<<endl;
cout<<"enter 4 to postorder dispaly"<<endl;
cout<<"enter 5 to level wise display"<<endl;
cin>>choice;
switch(choice)
{
case 1:
cout<<"enter value"<<endl;
cin>>a;
root=insertNode(root,a);
break;
case 2:
pre_orderdisplay(root);
break;
case 3:
in_orderdisplay(root);
break;
case 4:
post_orderdisplay(root);
break;
case 5:
level_orderdisplay(root);
break;
default:
break;
}
cout<<"prees y to continue"<<endl;
cout<<"press n to exist"<<endl;
cin>>ch;
}
}
c++ how to make function that sum the number
#include<iostream>
using namespace std;
void sum (int&, int&);
main()
{
int a,b;
cin>>a>>b;
sum(a,b);
}
void sum(int &c, int &d)
{
int sum;
sum=c+d;
cout<<"sum is: "<<sum;
}
using namespace std;
void sum (int&, int&);
main()
{
int a,b;
cin>>a>>b;
sum(a,b);
}
void sum(int &c, int &d)
{
int sum;
sum=c+d;
cout<<"sum is: "<<sum;
}
c++ program that find isosceles triangle equilateral triangle right angle triangle and scalene triangle
#include <iostream>
using namespace std;
main(){
int side1,side2,side3,a,b,c;
cout<<"Enter first side =";
cin>>side1;
cout<<"Enter second side=";
cin>>side2;
cout<<"Enter third side=";
cin>>side3;
if(side1==side2 && side2==side3 && side1==side3)
{
cout<<"isosceles triangle";
}
else if (side1==side2==side3)
{
cout<<"equilateral triangle";
}
else if(c*c==a*a+b*b || b*b==a*a+c*c || a*a==b*b+c*c )
{
cout<<"right angle triangle";
}
else
{
cout<<"scalene triangle";
}
}
using namespace std;
main(){
int side1,side2,side3,a,b,c;
cout<<"Enter first side =";
cin>>side1;
cout<<"Enter second side=";
cin>>side2;
cout<<"Enter third side=";
cin>>side3;
if(side1==side2 && side2==side3 && side1==side3)
{
cout<<"isosceles triangle";
}
else if (side1==side2==side3)
{
cout<<"equilateral triangle";
}
else if(c*c==a*a+b*b || b*b==a*a+c*c || a*a==b*b+c*c )
{
cout<<"right angle triangle";
}
else
{
cout<<"scalene triangle";
}
}
Subscribe to:
Posts (Atom)