Sei sulla pagina 1di 72

1.

AREA CALCULATION

PROGRAM:

#include<iostream.h>

#include<conio.h>

#include<math.h>

struct point

intx,y;

};

point p[3];

void area(float b,float h)

float temp;

temp = 0.5*b*h;

cout<<"\n THE AREA IS :"<<temp<<"sq.cm";

void area (float s1,float s2,float s3)

float temp;

temp = (s1+s2+s3)/2;

cout<<"\nThe Area Is:"<<sqrt(temp*(temp-s1)*(temp-s2)*(temp-s3))<<"sq.cm";

void area(point p1,point p2, point p3)


{

float temp;

temp = (p1.x*(p2.y-p3.y))+(p2.x*(p3.y-p1.y))+(p3.x*(p1.y-p2.y));

cout<<"\n THE AREA IS:"<<fabs(0.5*temp)<<"sq.cm";

void main()

floatbase,ht,a,b,c;

intch;

char c1;

do

{ clrscr();

cout<<"\t\t\t-------------------\n";

cout<<"\t\t\t AREA CALCULATION \n";

cout<<"\t\t\t-------------------\n";

cout<<"\n1.BASE HEIGHTS. \n2. THREE POINTS \n3. THREE SIDES";

cout<<"\n ENTER YOUR CHOICE:";

cin>>ch;

switch(ch)

case 1:

cout<<"\nEnter Base Length(in cm):";

cin>>base;

cout<<"Enter the height:";

cin>>c;
area(base,c);

break;

case 2:

for(int i = 0;i<3;i++)

cout<<"\n ENTER THE X CoORD. OF POINTS:"<<i+1<<":";

cin>>p[i].x;

cout<<"\n ENTER THE Y CoORD. OF POINTS:"<<i+1<<":";

cin>>p[i].y;

area(p[0],p[1],p[2]);

break;

case 3:

cout<<"\n ENTER FIRST SLIDE (in cm):";

cin>>a;

cout<<"\n ENTER SECOND SLIDE:";

cin>>b;

cout<<"\n ENTER THIRD SLIDE (:";

cin>>c;

area(a,b,c);

break;

cout<<"\n DO YOU WANT TO CONTINUE? (Y/N): ";

cin>>c1;

}
while(c1 == 'Y' ||c1 == 'y');

OUTPUT:

2. ELECTRICITY BILL

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

structbl

int no;

char name[20];

floatunit,bill;

}a;

void main()

clrscr();
cout<<"Enter consumer number:";

cin>>a.no;

cout<<"Enter consumer name:";

gets(a.name);

cout<<"Enter no. of units consumed:";

cin>>a.unit;

if(a.unit<=100)

a.bill=a.unit*0.4;

if(a.unit>100 &&a.unit<=200)

a.bill=(a.unit-100)*0.5+40;

if(a.unit>200 &&a.unit<=300)

a.bill=(a.unit-200)*0.75+90;

if(a.unit>300)

a.bill=(a.unit-300)*1+165;

cout<<"\nBill";

cout<<"\nConsumer No:"<<a.no;

cout<<"\nName:"<<a.name;

cout<<"\nUnits consumed:"<<a.unit;

cout<<"\nNet amount=Rs"<<a.bill;

getch();

OUTPUT:
3. STUDENT MARK & AVERAGE LIST

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

int i;

class student

private:

intadmno;

charsname[21];

float mark[5],total;

float calculate();

public:

voidtakedata();

voidshowdata();
}s;

float student::calculate()

float per;

total=0;

for(i=0;i<5;i++)

total+=mark[i];

per=total/5;

return per;

void student::showdata()

cout<<"\nAdmission no:"<<admno;

cout<<"\nName:"<<sname;

cout<<"\nMarks-";

for(i=0;i<5;i++)

cout<<"\nSubject"<<i+1<<":"<<mark[i];

cout<<"\nTotal="<<total;

cout<<"\nAverage="<<calculate();

void student::takedata()

cout<<"Enter admission no:";

cin>>admno;

cout<<"Enter name:";
gets(sname);

for(i=0;i<5;i++)

cout<<"Enter marks in subject"<<i+1<<":";

cin>>mark[i];

calculate();

showdata();

void main()

clrscr();

cout<<"STUDENT RECORD DATABASE\n\n";

s.takedata();

getch();

OUTPUT:
4. AREA OF A CIRCLE USING ASSIGNMENT OPERATOR

#include<iostream.h>

#include<conio.h>

class circle

floatradius,area;

public:

circle(float r)

radius=r;

area=3.14*r*r;

circle(circle &c)

{
radius=c.radius+1;

area=3.14*radius*radius;

void display()

cout<<"\nRadius="<<radius;

cout<<"\nArea="<<area;

};

void main()

float rad;

clrscr();

cout<<"Enter radius:";

cin>>rad;

circle c1(rad);

cout<<"\nBefore incrementing radius:";

c1.display();

circle c2(c1);

cout<<"\nAfter copying incremented radius:";

c2.display();

getch();

OUTPUT:
5. FINDING VOWELS, DIGITS, CONSONANTS,WHITE SPACES

#include<iostream.h>

#include<string.h>

#include<conio.h>

int main()

clrscr();

char line[150];

inti,v,c,d,s;

v=c=d=s=0;

cout<< "Enter a line of string: " <<endl;

cin.getline(line, 150);

for(i=0;line[i]!='\0';++i)

if(line[i]=='a'

|| line[i]=='e'

|| line[i]=='i'

|| line[i]=='o'

|| line[i]=='u'
|| line[i]=='A'

|| line[i]=='E'

|| line[i]=='I'

|| line[i]=='O'

|| line[i]=='U')

++v;

else if((line[i]>='a'&& line[i]<='z')

|| (line[i]>='A'&& line[i]<='Z'))

++c;

else if(line[i]>='0'&&c<='9')

++d;

else if (line[i]==' ')

++s;

cout<< " Vowels: " << v <<endl;

cout<< " Consonants: " << c <<endl;

cout<< " Digits: " << d <<endl;

cout<< " White Spaces: " << d <<endl;

getch();

return 0;

OUTPUT:
6. TELEPHONE BILL

PROGRAM:

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

classaddr

int block;

char street[20];

char city[20];

public:

void input()

cout<"Enter Address:\n";

cout<<"Enter Block Number:";

cin>>block;

cout<<"Enter Street Name:";


gets(street);

cout<<"Enter city :";

gets(city);

void output()

cout<<"Address :"<<block<<endl;

puts(street);

puts(city);

};

Class telephonebill

char name[100];

addr address;

longphone_no;

intcalls,rent;

floatcharge,subtotal,subcharge,total;

public:

telephonebill()

rent=500;

void input()

{
cout<<"Enter name:";

gets(name);

cout<<"Enter the Telephone number:";

cin>>phone_no;

address.input();

cout<<"Enter the number of calls made:";

cin>>calls;

voidcalbill()

charge =0.0;

if(calls<=150)charge=0.0;

else if(calls<=300)charge=(calls-150)*1.0;

else if(calls<=450)charge=150+((calls-450)*1.5);

else charge=375+((calls-450)*2.0);

subcharge=0.2*charge;

total=rent+charge+subcharge;

void output()

cout<<"\nName:"<<name;

cout<<"\nPhone Number:"<<phone_no;

cout<<"\nNumber of calls:"<<calls;

cout<<"\nBill is:"<<total<<"/-\n";

}
};

int n;

void main()

clrscr();

telephonebill t[10];

cout<<"\t\t\t----------------------\n";

cout<<"\t\t\tTelephone Bill\n";

cout<<"------------------------\n";

cout<<"Enter the number of customers:";

cin>>n;

for(int i=0;i<n;i++)

t[i].input();

t[i].calbill();

for(i=0;i<n;i++)

t[i].output();

getch();

OUTPUT:
7.Simple calculator

#include<iostream.h>

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

void main()

clrscr();

float a, b, res;

char choice, ch;

do

cout<<"1.Addition\n";

cout<<"2.Subtraction\n";

cout<<"3.Multiplication\n";

cout<<"4.Division\n";

cout<<"5.Exit\n\n";
cout<<"Enter Your Choice : ";

cin>>choice;

switch(choice)

case '1' : cout<<"Enter two number : ";

cin>>a>>b;

res=a+b;

cout<<"Result = "<<res;

break;

case '2' : cout<<"Enter two number : ";

cin>>a>>b;

res=a-b;

cout<<"Result = "<<res;

break;

case '3' : cout<<"Enter two number : ";

cin>>a>>b;

res=a*b;

cout<<"Result = "<<res;

break;

case '4' : cout<<"Enter two number : ";

cin>>a>>b;

res=a/b;

cout<<"Result = "<<res;

break;

case '5' : exit(0);

break;

default :cout<<"Wrong Choice..!!";

break;
}

cout<<"\n------------------------------------\n";

}while(choice!=5 && choice!=getchar());

getch();

Output

8. To Return A Structured Variable (Larger Timing)

#include <iostream.h>

#include <iomanip.h>

struct Time

intHrs;

int Min;

};

void main()

Time t1,t2,t3;
Time Larger(Time,Time); // prototype

voidDisplayTime(Time); // prototype

cout<<endl;

cout<<"Enter time-1: Hrs.: ";

cin>>t1.Hrs;

cout<<" : Min.: ";

cin>>t1.Min;

cout<<"Enter time-2: Hrs.: ";

cin>>t2.Hrs;

cout<<" : Min.: ";

cin>>t2.Min;

t3=Larger(t1,t2);

cout<<"Larger time : ";

DisplayTime(t3);

Time Larger(Time tt1, Time tt2) // to return type Time

Time temp;

if (tt1.Hrs>tt2.Hrs)

temp=tt1;

else
if (tt1.Hrs<tt2.Hrs)

temp=tt2;

else

if (tt1.Min>tt2.Min)

temp=tt1;

else

temp=tt2;

return temp;

voidDisplayTime(Time tt)

cout.fill('0');

cout<<setw(2)<<tt.Hrs<<":"

<<setw(2)<<tt.Min<<endl;

OUTPUT:

9. Copy constructor

#include<conio.h>

#include<iostream.h>
#include<string.h>

class student

int roll;

int age;

char name[30];

public:

student()

cout<<"\n Constructor:";

roll=10;

age =18;

strcpy(name,"Rahul");

student(student &s)

cout<<"\n Copy constructor:";

roll=s.roll;

age =s.age;

strcpy(name,s.name);

voidinput_void()

cout<<"\n Enter roll no:";

cin>>roll;

cout<<"\nEnter the Age;";

cin>>age;
cout<<"\n Enter name:";

cin>>name;

voidshow_data()

cout<<"\n Roll no:";

cout<<roll;

cout<<"\n Age:";

cout<<age;

cout<<"\n Name:";

cout<<name;

}};

void main()

clrscr();

student s;

s.show_data();

cout<<"\n";

student A(s);

A.show_data();

getch();

Output
10.Multiple Inheritance

#include<iostream.h>

#include<stdio.h>

#include<conio.h>

class person

char name[21];

int age;

public:

voidindata()

{cout<<"\n\nEnter the name of Student: " ;

gets(name);

cout<<"\n\nEnter the age : ";

cin>>age;

voidoutdata();

};

void person::outdata()

{
cout<<"\n\n";

for(int i=0; i<79; i++)

cout<<"-";

cout<<"\n\nName of the student is: "<<name;

cout<<"\n\nAge of the student is : "<<age;

class game {

chargame_name[20];

public:

void input()

cout<<"\n\nEnter the game name : ";

cin.get();cin.getline(game_name,20);

void output()

cout<<"\n\nGame opted by the student is : "<<game_name;

};

class student: public person, public game

{ floatTmarks;

introllno;

public:

charcalgrade()

{if(Tmarks>90)

return 'A';
else if(Tmarks>80&&Tmarks<=90)

return 'B';

else if(Tmarks>70&&Tmarks<=80)

return 'C';

else if(Tmarks>60&&Tmarks<=70)

return 'D';

else

return 'E';

void enter()

indata();

cout<<"\n\nEnter the roll number: "; cin>>rollno;

input();

cout<<"\n\nEnter total marks (out of 100) : ";

cin>>Tmarks;

void display()

outdata();

cout<<"\n\nRoll number : "<<rollno;

output();

cout<<"\n\nTotal marks are : "<<Tmarks;

cout<<"\n\nGrade = "<<calgrade();

}
};

void main()

{ clrscr();

student A;

A.enter();

cout<<”\n\nstudent details are : \n\n”;

A.display();

getch();

Output:

11. CALCUALTING BILL USING DATA FILE HANDLING

#include<fstream.h>
#include<iomanip.h>

#include<conio.h>

// file of records

struct item

int code;

floatqty,price;

char name[20];

}it;

floatgtot=0;

voidcre()

int n;

ofstreamfout("item.dat", ios::binary|ios::app);

cout<<"\n how many item:";

cin>>n;

cout<<"\n enter code, qty, price & name of item\n";

for(int i=1;i<=n;i++)

cin>>it.code>>it.qty>>it.price>>it.name;

fout.write((char*)&it, sizeof(it));

fout.close();

void aces()
{

float tot;

ifstream fin("item.dat",ios::binary);

cout<<"\n content of file after bill calculation\n";

cout<<setw(6)<<"code"<<setw(20)<<"name"<<setw(7)<<"qty";

cout<<setw(7)<<"price"<<setw(7)<<"total"<<endl;

while(fin)

fin.read((char*)&it, sizeof(it));

if(fin)

tot = it.qty*it.price;

gtot+=tot;

cout<<setw(6)<<it.code<<setw(20)<<it.name<<setw(7)<<it.qty;

cout<<setw(7)<<it.price<<setw(7)<<tot<<endl;

cout<<"\n bill to be paid Rs."<<gtot;

void main()

clrscr();

cre();

aces();

getch();
}

OUTPUT:

12. Enter any line or character in a file and press * to exit the program .

#include<iostream.h>

#include<fstream.h>

#include<conio.h>

void main()

charch;

clrscr();

ofstream f1("emp.txt");

cout<<"\nEnter char ";

while(1)

ch=getche();

if(ch=='*')

break;

if(ch==13)

{
cout<<"\n";

f1<<'\n';

f1<<ch;

f1.close();

getch();

Output

13. Enter the Students Details using File Handling

#include<fstream.h>

#include<conio.h>

void main()

clrscr();
int a[10]; float b[10];

for(int i=0; i<10; i++)

cout<<"\n\nEnter the roll no. of student "<<i+1<<" : "; cin>>a[i];

cout<<"\n\tEnter the marks of student "<<i+1<<" => "; cin>>b[i];

ofstream student;

student.open("stud.txt");

for(i=0; i<10; i++)

student<<"\n\nMarks of roll no. "<<a[i]<<" => "<<b[i];

student.close();

i=0;

cout<<”\n\nStudent details are :\n\n”;

charstr[80][80];

ifstreamstude;

stude.open("stud.txt",ios::in);

stude.seekg(0);

while(!stude.eof())

stude.getline(str[i],80);

cout<<str[i]<<"\n\n";

i++;

}
getch();

}
14. Selection Sort

#include<conio.h>

#include<iostream.h>

#include<iomanip.h>

void main()

clrscr();

int x[10],i,j,temp,low,pos;

cout<<"\n Enter 10 numbers to be sort:";

for(i=0;i<10;i++)

cin>>x[i];

for(i=0;i<9;i++)

low=x[i];

pos=i;

for(j=i+1;j<10;j++)

if(low>x[j])

low=x[j];

pos=j;

temp=x[i];

x[i]=x[pos];

x[pos]=temp;
} // end of i for loop

// output phase

cout<<"\n Sorted Array:";

for(i=0;i<10;i++)

cout<<setw(4)<<x[i];

getch();

return ;

Output

15. Deleting an element

#include<iostream.h>

#include<conio.h>

void main()

clrscr();

intarr[50], size, i, del, count=0;

cout<<"Enter array size : ";

cin>>size;

cout<<"Enter array elements : ";


for(i=0; i<size; i++)

cin>>arr[i];

cout<<"Enter element to be delete : ";

cin>>del;

for(i=0; i<size; i++)

if(arr[i]==del)

for(int j=i; j<(size-1); j++)

arr[j]=arr[j+1];

count++;

break;

if(count==0)

cout<<"Element not found..!!";

else

cout<<"Element deleted successfully..!!\n";

cout<<"Now the new array is :\n";

for(i=0; i<(size-1); i++)

{
cout<<arr[i]<<" ";

getch();

Output

16. SORTING AND SEARCHING OF AN ELEMENT

Binary search(sorting and Searching)

#include<iostream.h>

#include<conio.h>

void sort(int a[],int n)

intsmall,pos,temp;

for(inti=0;i<n;i++)

small=a[i];

pos=i;

for(int j=i;j<n;j++)

if(a[j]<small)

{
small=a[j];

pos=j;

temp=a[i];

a[i]=a[pos];

a[pos]=temp;

cout<<"sorted array is: ";

for(i=0;i<n;i++)

cout<<a[i];

void search(int a[],intn,int item)

int ll,u1,mid;

int flag=0;

ll=0;u1=n-1;

while(ll<=u1)

mid= (ll+u1)/2;

if(item==a[mid])

flag++;

cout<<item<<"present in position: "<<mid+1;

if(item<a[mid])

u1=mid-1;

else
ll=mid+1;

if(flag==0)

cout<<"\n elements not found";

void main()

int a[20];

int n, item;

charch;

clrscr();

do

cout<<"\t\tSORTING AND SEARCHING"<<endl;

cout<<"\t\t**********************";

cout<<"\n\n Enter the size: ";

cin>>n;

cout<<"enter the elements of the array: ";

for(inti=0;i<n;i++)

cin>>a[i];

sort(a,n);

cout<<"enter the elements to be searched: ";

cin>>item;

search(a,n,item);

cout<<"\n\nDo you wish to continue? (Y/N)";

cin>>ch;

}while(ch=='Y'||ch=='y');

getch();
}

17. INSERTING AN ELEMENT


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();

inti,a[50],no,pos,size;
cout<<"Enter array size( Max:50 ) :: ";
cin>>size;
cout<<"\nEnter array elements :: \n";

for(i=0; i<size; i++)


{
cout<<"\nEnterarr["<<i<<"] Element :: ";
cin>>a[i];
}

cout<<"\nStored Data in Array :: \n\n";

for(i=0;i<size;i++)
{
cout<<" "<<a[i]<<" ";
}

cout<<"\n\nEnter position to insert number :: ";


cin>>pos;

if(pos>size)
{
cout<<"\nThis is out of range.\n";
}
else
{
cout<<"\nEnter number to be inserted :: ";
cin>>no;
--pos;

for(i=size;i>=pos;i--)
{
a[i+1]=a[i];
}
a[pos]=no;

cout<<"\nNew Array is :: \n\n";

for(i=0;i<size+1;i++)
{
cout<<" "<<a[i]<<" ";
}

}
cout<<"\n";
getch();
}

Inserting an element output


18. BUBBLE SORT

#include<iostream.h>

#include<conio.h>

void main()

clrscr();

int a[50],n,i,j,temp;

cout<<"Enter the size of array: ";

cin>>n;

cout<<"Enter the array elements: ";


for(i=0;i<n;++i)

cin>>a[i];

for(i=1;i<n;++i)

for(j=0;j<(n-i);++j)

if(a[j]>a[j+1])

temp=a[j];

a[j]=a[j+1];

a[j+1]=temp;

cout<<"Array after bubble sort:";

for(i=0;i<n;++i)

cout<<" "<<a[i];

getch();

OUTPUT:
19. MERGING OF AN ARRAY

#include<iostream.h>

#include<conio.h>

void Merge(int A[], int B[], int C[], int N, int M, int&K);

int main()

clrscr();

int A[100], B[100], C[200],i,n,m,k;

cout<<"\nEnter number of elements you want to insert in first array ";

cin>>n;

cout<<"Enter element in ascending order\n";


for(i=0;i<n;i++)

cout<<"Enter element "<<i+1<<":";

cin>>A[i];

cout<<"\nEnter number of elements you want to insert in second array ";

cin>>m;

cout<<"Enter element in descending order\n";

for(i=0;i<m;i++)

cout<<"Enter element "<<i+1<<":";

cin>>B[i];

Merge(A,B,C,n,m,k);

cout<<"\nThe Merged Array in Ascending Order"<<endl;

for(i=0;i<k;i++)

cout<<C[i]<<" ";

getch();

return 0;

void Merge(int A[], int B[], int C[], int N, int M, int&K)

{
int I=0, J=M-1;

K=0;

while (I<N && J>=0)

if (A[I]<B[J])

C[K++]=A[I++];

else if (A[I]>B[J])

C[K++]=B[J--];

else

C[K++]=A[I++];

J--;

for (int T=I;T<N;T++)

C[K++]=A[T];

for ( T=J;T>=0;T--)

C[K++]=B[T];

OUTPUT:
20. Stack using Push & Pop

#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<stdio.h>

struct node
{
char name[20];
int age;
node *link;
}*ptr=NULL,*save=NULL;
class stack
{
node *top;
public:
stack()
{top=NULL;
}
voidstackpush();
voidstackpop();
void display();
}st;

void stack::stackpush()
{ptr=new node;
if(ptr==NULL)
{cout<<"Overflow ";
}
else
{cout<<"Enter the name ";
gets(ptr->name);
cout<<"Enter the age ";
cin>>ptr->age;
ptr->link=NULL;
if(top==NULL)
{top=ptr;
}
else
{ptr->link=top;
top=ptr;
}
}
}

void stack::stackpop()
{if(top==NULL)
{cout<<"Underflow ";
}
else
{save=top;
top=top->link;
cout<<"Name ";
puts(save->name);
cout<<"Age "<<save->age;
delete save;
}
}

void stack::display()
{if(top==NULL)
{cout<<"No elements.."<<endl;
}
else
{ptr=top;
while(ptr!=NULL)
{cout<<"\nName ";
puts(ptr->name);
cout<<"Age "<<ptr->age;
ptr=ptr->link;
}
}
}
void main()
{clrscr();
intch;
X:
cout<<"\nEnter your choice\n1.PUSH\n2.POP\n3.DISPLAY\n4.EXIT\n";
cin>>ch;
switch(ch)
{case 1:st.stackpush();
goto X;
case 2:st.stackpop();
goto X;
case 3:st.display();
goto X;
default:cout<<"Wrong choice ";
goto X;
case 4:exit(0);
}
getch();
}

Output
21. Queue using Insert and Delete
#include <iostream>
#include<conio.h>
#include<stdlib.h>
#define MAX_SIZE 100
int main() {
int item, choice, i;
intarr_queue[MAX_SIZE];
int rear = 0;
int front = 0;
int exit = 1;

cout<< "\nSimple Queue Example - Array";


do {
cout<< "\n\n Queue Main Menu";

cout<< "\n1.Insert \n2.Remove \n3.Display \nOthers to exit";


cout<< "\nEnter Your Choice : ";
cin>>choice;
switch (choice) {
case 1:
if (rear == MAX_SIZE)
cout<< "\n## Queue Reached Max!!";
else {
cout<< "\nEnter The Value to be Insert : ";
cin>>item;
cout<< "\n## Position : " << rear + 1 << " , Insert Value : " << item;
arr_queue[rear++] = item;
}
break;
case 2:
if (front == rear)
cout<< "\n## Queue is Empty!";
else {
cout<< "\n## Position : " << front << " , Remove Value :" <<arr_queue[front];
front++;
}
break;
case 3:
cout<< "\n## Queue Size : " << (rear - front);
for (i = front; i < rear; i++)
cout<< "\n## Position : " << i << " , Value : " <<arr_queue[i];
break;
default:
exit = 0;
break;
}
} while (exit);

return 0;
}
Output
22. Circular Queue

#include<iostream.h>

#include<stdlib.h>

#include<conio.h>

#include<stdio.h>

class Cir_Q

int info[100];

int front;rear;
public:

Cir_Q()

front=rear=0;

void insertion(int);

int deletion();

void disp();

};

void Cir_Q::insertion(int no)

if((rear+1)%100==front)

cout<<endl<<"circular queue is full\n";

else

rear=(rear+1)%100;

info[rear]=no;

int Cir_Q::deletion()

int no=-999;

if(front==rear)

cout<<endl<<"circular queue is empty\n";

else
{

front=(front+1)%100;

no=info[front];

return(no);

void Cir_Q::disp()

int i;

if(front==rear)

cout<<endl<<"circular queue is empty";

else

cout<<endl<<"circular queue is not empty";

i=front;

cout<<endl<<"the elements are:"<<endl;

do

i=(i+1)%100;

cout<<info[i]<<"\n";

}while(i!=rear);

void main()

{
Cir_Q q;

int n,ch;

do

clrscr();

cout<<"\nCircular Queue operations";

cout<<endl<<"1.Insertion\n";

cout<<"2.Deletion\n";

cout<<"3.Display\n";

cout<<"4.Quit\n";

cout<<"Enter your choice:";

cin>>ch;

switch(ch)

case 1:

cout<<endl<<"Enter the number to be inserted in queue:";

cin>>n;

q.insertion(n);

break;

case 2:n=q.deletion();

if(n!=-999)

cout<<"The deleted info is:\t"<<n;

break;

case 3:q.disp();

break;
case 4:exit(0);

}getch();

}while(ch!=4);

Output
SQL QUERIES

SQL: 1

1. Write a SQL queries for the following on the basis of given table student.

To Create a Table in SQL:

FORM DESIGN:

1. To display sname & age from student.


2. To display all the records of simran;

3. To display all the records which has sno between 50000 to 70000.

4. To display all names which has male sex.

5. To display all marks between 400 to 500.


6. To display the sno in ascending order.

SQL: 2

2. Write SQL queries for the following on the basis of given table employees.

To create a table in SQL:

FORM DESIGN:
1. Display empno & ename of all employees from the table employees.

2. Display all salary from employees in ascending order.

3. Display employees number,name,sal whose commission is not null from


table employees.
4. Display all records of employees whose job is clerk.

5. List the detail of those employees whose salary is between 2000 to 5000.

SQL: 3

3. Write SQL queries for the following on the basis of given table sports.

To Create a Table in SQL:

FORM DESIGN:
1. Display the names of the students who are getting grade ‘c’ in sports.

1. Display the different games offered in the school.

2. Display the all records of Surjeet.

3. Display the names of those students who study in class 10.


4. Display the records of those students who have cricket as their game.

SQL: 4

4. Write SQL queries for the following on the basis of given table teacher.

To Create a Table in SQL:

FORM DESIGN:

1. Display all information about the teacher of maths department.

2. Display all the names of female teachers.


3. Display all records of computer teacher.

4. Display all the names of those teachers who is earning salary of more than
20000.

5. Display all the names of those teachers who is not less than 40 years.

SQL: 5

5. Write SQL queries for the following on the basis of given table pet.

To Create a Table in SQL:

FORM DESIGN:
1. Display all the records of Tommy.

2. Display all the names of the owners.

3. Display name of those pet whose sex is female.

4. Display all the records of those pets who is having sex null.

5. Display all the records of pet whose species are dog.


SQL:6

To display the details of those Customer whose City is Delhi.


SELECT * FROM CUSTOMER WHERE CITY = 'DELHI';

To display the details of Item whose Price is in the range of 3500 to 55000 (Both
values included).
SELECT * FROM ITEM WHERE PRICE BETWEEN 35000 AND 55000;

To displa the customerName, City from table Customer, and ItemName


and Price from table Item, with their corresponding matching I_ID.
SELECT CUSTOMERNAME,CITY,ITEMNAME,PRICE FROM CUSTOMER
A INNER JOIN ITEM B WHERE A.I_ID=B.I_ID;

To increase the Price of all Items by 1000 in the table Item.


UPDATE ITEM SET PRICE=PRICE+1000;

SELECT DISTINCT City FROM Customer;


City

Delhi

Mumbai

Banglore

SELECT ItemName, Max(Price), Count(*) FROM Item GROUP BY


ItemName;
Name Max(Price) Count(*)
Laptop 58000 2
Personal 38000 3
Computer
SELECT CustomerName, Manufacturer From Item, Customer WHERE
Item.I_Id=Customer.I_Id;
Cname Manufacturer
N Roy PQR
H Singh XYZ
R Pandey COMP
C Sharma PQR
K
Agarwal ABC

SELECT ItemName, Price * 100 FROM Item WHERE Manufacturer =


‘ABC’;
Name Price*100
Personal Computer 3600000
Laptop 5600000

To display the RecID, SenderName, SenderAddress, RecName, RecAddess for


every Recipient
SELECT RECID,
SENDERNAME,SENDERADDRESS,RECNAME,RECADDRESS FROM
RECIPIENT A INNER JOIN SENDER B ON A.SENDERID=B.SENDERID;

To display Recipient detail in asending order of RecName


SELECT * FROM RECIPIENT ORDER BY RECNAME;

To display number of Recipients from each city


SELECT RECCITY,COUNT(RECNAME) FROM RECIPIENT GROUP BY
RECCITY;

SELECT DISTINCT Sendercity FROM Sender;


Sendercity

New Delhi

Mumbai
SELECT A.SenderName, B.RecName FROM Sender A, Recipient B WHERE
A.SenderID=B.SenderID AND B.RecCity=’Mumbai’;

SenderName RecName

R Jain H Singh
S Jha P K Swamy

SELECT RecName, RecAddress FROM Recipient WHERE recCity NOT


IN(‘Mumbai’, ‘Kolkata’);
RecName RecAddress
S Mahajan 116, A Viharl
S Tirupati 13, B1 D, Mayur Vihar

SELECT RecID, RecName FROM Recipient WHERE SenderID=’MU02’ OR


SenderID=’ND50’;
RecID RecName

ND08 S Mahajan
ND48 S Tirupati

Potrebbero piacerti anche