INDEX

SR.N O.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

ASSIGNMENT
Assignment No. 1 Assignment No. 2 Assignment No. 3 Assignment No. 4 Assignment No. 5 Assignment No. 6 Assignment No. 7 Assignment No. 8 Assignment No. 9 Assignment No. 10 Assignment No. 11 Assignment No. 12 Assignment No. 13 Assignment No. 14 Assignment No. 15 Assignment No. 16 Assignment No. 17 Assignment No. 18 Assignment No. 19

DATE
04-112011 04-112011 04-112011 04-112011 04-112011 04-112011 04-112011 05-112011 05-112011 05-112011 25-122011 25-122011 25-122011 26-122011 26-122011 26-122011 27-122011 27-122011 27-122011

SIGNATURE

20 21 22 23 24 25 26 27

Assignment No. 20 Assignment No. 21 Assignment No. 22 Assignment No. 23 Assignment No. 24 Assignment No. 25 Assignment No. 26 Assignment No. 27

28-122011 28-122011 28-122011 29-122011 29-122011 29-122011 03-012012 04-012012

ASSIGNMENT -1
Q. Rewrite the following program after removing syntactical errors (if any):
#include<iostream.h> const int MAX 10; void main() { cout<<endl; int Numbers[MAX]; Numbers={20,50,10,30,40}; For(Loc=MAX-1; Loc>=0; Loc--) Cout>>Numbers[Loc]; } Answer . Correct code is: #include<iostream.h> const int MAX=10; void main() { int Numbers[MAX]; Numbers={20,50,10,30,40}; for(int Loc=MAX-1; Loc>=0; Loc--) cout<<Numbers[Loc]; }

Q. What will be the output of following compiled program code? #include<iostream.h> #include<ctype.h> void main() { char Text[]="Mind@Work"; for(int l=0; Text[l]!='###BOT_TEXT###'; l++) { if(!isalpha(Text[l])) Text[l]='*'; else if(isupper(Text[l])) Text[l]=Text[l]+1; else Text[l]=Text[l+1]; } cout<<Text; } ANS. Output will be: Nnd@*Xrk

ASSIGNMENT-2

ASSIGNMENT-3
Q. Find the output of following program: #include<iostream.h> void Withdef(int HisNum=30) { for(int l=20; l<=HisNum; l+=5) cout<<l<<","; cout<<endl; } void Control(int &MyNum) { MyNum+=10; Withdef(MyNum); } void main() { int YourNum=20; Control(YourNum); Withdef(); cout<<"Number= "<<YourNum<<endl; }

ANS. Output will be:
20,25,30,

Number= 20 ASSIGNMENT-4 Q.35.22.92. cout<<MyMarks<<endl. MyMarks. int Marks[]={99. Output will be: 92 or 94 . } ANS.h> void main() { randomize().95}. What will be the expected output of the following program? #include<iostream.93. MyMarks=Marks[1+random(2)].96.h> #include<stdlib.25.94.

l<=4. void main() { randomize(). l++) { Number=LOW+random(Point). cout<<Number<<":". for(int l=1. } } ANS. Point--.ASSIGNMENT-5 Q.h> #include<stdlib. int Point=5.h> const int LOW=25. The possible outputs could be: 25:28:27:26: . What will be the output of the following program? #include<iostream. Number.

ASSIGNMENT-6 Q.28:28:26:25: 29:25:27:26: 26:26:26:26: etc . What will be the output of the following program? #include<iostream. Qty=100. char Item[20].."Rice"). strcpy(Item. Price=25. public:Retail() //Function1 { strcpy(Category."Cereal").h> class Retail { char Category[20]. . float Price. int Qty.h> #include<string.

but <= 20. penalty =2 Otherwise. void main() { Retail R. Output will be: Cereal-Rice:100@25 ASSIGNMENT-7 Q. Define a class CRICKET with following description: • Private members: Target_score (integer) Overs_bowled (integer) Extra_time (integer) penalty (integer) A member function calc_penalty( ) to calculate penalty as follows: If Extra_time <= 10. Overs_bowled & Extra_time .} void Show() { cout<<Category<<"-"<<Item<<":"<<Qty<<"@" <<Price<<endl. penalty = 5 • Public members ∗ A member function extdata( ) to allow user to enter values for Target_score. //Statement1 R. } }. //Statement2 } ANS. penalty = 1 If Extra_time > 10.Show().

ANS. cin>>Overs bowled. else penalty=5. cin>>Extra time. if(Extra time>10&&Extra time<=20) penalty=2. cin>>Target score. Overs bowled. . cout<<"Enter Extra Time: ". Extra time. cout<<"Target Score: "<<Target score<<endl. } }. cout<<"Penalty: "<<penalty. } void dspdata() { calc penalty(). cout<<"Overs Bowled: "<<Overs bowled<<endl. penalty. cout<<"Extra Time: "<<Extra time<<endl. } public:void extdata() { cout<<"Enter Target Score: ". cout<<"Enter Overs Bowled: ". void calc penalty() { if(Extra time<=10) penalty=1. The required class should be: class CRICKET { int Target score.∗ A member function dspdata( ) to call calc_penalty( ) function and display all the data members.

Public Members: • A constructor to assign initial values as follows: * TCode with the word “NULL” * NoofAdults. NoofKids.ASSIGNMENT-8 Q. NoofKids(as integer). Kilometers & TotalFare as 0 • A function AssignFare( ) which calculates and assigns the value of the data members TotalFare as follows: For each Adult Fare(Rs) For Kilometers . Define a class Tour with the description below: Private Members: TCode(as string). Kilometers(as integer) & Totalfare(as float). NoofAdults(as integer).

A function ShowTour( ) which displays the content of all the data members for a Tour. The required class should be: class Tour { char *TCode[50]. . int No of Adults. cout<<"Enter No.500 >= 1000 300 < 1000 & >= 500 200 < 500 For each Kid the above Fare will be 50% of the Fare mentioned in the above table • A function EnterTour( ) to input the values of the data members TCode. NoofAdults=NoofKids=Kilometers=TotalFare=0. float Total Fare. cin>>NoofAdults. Kilometers. public: Tour() { *TCode="NULL". else if(Kilometers<1000&&Kilometers>=500) Total Fare=No of Adults*300+NoofKids*150. of Adults: ". and invoke the AssignFare( ) function. else if(Kilometers<500) Total Fare=No of Adults*200+NoofKids*100. gets(*TCode). NoofKids & Kilometers. NoofAdults. } void AssignFare() { if(Kilometers>=1000) Total Fare=No of Adults*500+NoofKids*250. No of Kids. ANS. } void EnterTour() { cout<<"Enter TCode: ".

set and get function for every data member • A display function.of Adults: "<<NoofAdults<<endl<<"No. of Kids: ". of Kids: ". AssignFare(). and the getName member function. ASSIGNMENT-9 Q. a destructor For the Person class above. cout<<NoofKids<<endl<<"Distance:"<<Kilometers< <endl<< "Total Fare:"<<TotalFare . } void ShowTour() { cout<<"TCode: "<<*TCode<<endl<<"No. write each of the constructors. the assignment operator. cin>>Kilometers.cout<<"Enter No. Write a declaration for a class Person which has the following: • Data members name. Use member . cin>>NoofKids. phone. } }. cout<<"Enter distance in Kilometers: ".

. In the Person class above. n). } . public: void set Name(char * n) { strcpy(name. long phone. } void set Phone(long p) { phone = p. write the declaration for a class Spouse that inherits from Person & does the following: o Has an extra data member spouseName & Redefines the display member function ANS.".. Required classes should be: class Person { char name[50]. } long get Phone() { return phone.initialization lists as often as possible. } void display() { cout<<"Name: "<<name<<endl<<"Phone: "<<getPhone()<<endl. } char* get Name() { return name. } ~Person() { cout<<"In destruction mode.

display().Define a class employee with the following specifications: Private members of class employee empno integer ename 20 characters . class Spouse : public Person { char spouse Name[50]. cout<<"SpouseName:"<<getSpouseName(). spname). } char* getSpouse Name() { return spouse Name.}P. public: void set Spouse Name(char * spname) { strcpy(spouseName. } }SP. } void display() { P. ASSIGNMENT-10 Q.

char ename[20]. gets(ename). basic. da. float calculate() { return basic+hra+da. netpay=calculate(). cout<<"Enter H.R. netpay.basic. cout<<"Enter Employee name: ". cout<<"Enter D. hra. hra. Required class should be: class employee { int empno. } public: void have data() { cout<<"Enter Employee number: ". cin>>hra. cin>>empno.: ". . ename.A. cin>>da. da float netpay float calculate ( ) A function to find basic + hra + da with float return type public member function of class employee havedata ( ) function to accept values for empno. cout<<"Enter Basic: ". float basic.A. cin>>basic.: ". hra. da and invoke calculate ( ) to calculate netpay. dispdata ( ) function to display all the data members on the screen. ANS.

.R. cout<<"\nBasic: "<<basic<<"\nH.A.} void disp data() { cout<<"Employee number: "<<empno<<"\nEmployee name: "<<ename.A.: "<<hra<<"\nD. cout<<da <<"\nNet pay: "<<netpay.: ". } }.

lsearch(in . cout<<“Enter the length of the array (Max 50): ” . cin>>n. int l. } if(p!=-1) { cout<<”Element found at position: “<<p+1. i<n.Write a program for linear search. } . for(int i=0.n. i<l. } else cout<<”Element not in array!!”. cout<<”\nEnter the element to be searched: “. i++) cin>>in[i]. ANS. Required program should be: #include<iostream. i++) { if(a[i]==s) p=i.h> Void lsearch(int a[].ASSIGNMENT-11 Q.n . cout<<”Enter the array’s element: “. int s) { int p=-1.o). for(int i=0.o. cin>>o. } void main() { int in[50].

for(int i=0.o. i++) cin>>ar[i]. int s) { int b = 0. } void main() { int ar[50]. ANS. cin>>o. l = l-1.} else if(s>a[m]) b = m+1. Required program should be: #include<iostream.n. i<n. cin>>n. else l = m-1.n. int l. else cout<<”Element not in index!!”.h> void search(int a[]. p=-1. cout<<”Enter length of array (Max 50): ”. m. } if(p!= -1) cout<<”Element found at position “<<p+1.Write a program for binary search.o). search(ar. break. } . cout<<”Enter elements of array in ascending order: “. while(b<=l) { m = (b+l)/2.ASSIGNMENT-12 Q. if(s == a[m]){p = m. cout<<”Enter element to be searched: “.

j<((l-1)-i). cout<<”Enter array element: \n“. i<l. i++) for(int j=0. i<n. i++) cout<<ar[i]<<‘ ‘. j++) if(a[j]>a[j+1]) { int t = a[j]. cout<<”Enter the length of array (Max 50): “. sort(ar. Required program should be: #include<iostream. int l) { . cout<<”Array after sorting is: \n“. Write a program for bubble sort . a[j] = a[j+1]. i<n. cin>>n.h> void sort(int a[]. i++) cin>>ar[i]. for(i = 0.ASSIGNMENT-13 Q.n. for(int i = 0.n). a[j+1] = t. ANS. } . } } } void main() { int ar[50]. for(int i = 0.

\n”. for(i = 0.c. i++) cin>>B[i].. int C[]) { int a. merge(A. for(int i = 0.h> void merge(int A[]. cin>>N. b = n-1. } if(a<m) { while(a<m) C[c++] = A[a++]. ANS.b. Write a program for merge sort. else C[c++] = B[b--].B. i<N. cin>>M. i++) cin>>A[i].int m. i<M.C). B[50]. MN=0. cout<<”\n\nThe merged array is as shown bellow. Required program should be: #include<iostream. c = 0. M. int B[]. cout<<”\nEnter length of second array: “. cout<<”Enter length of first array: “. i++) cout<<C[i].N.int n.ASSIGNMENT-14 Q. for(i = 0.} } void main() { int A[50]. MN=M+N. N. for(a = 0. cout<<”Enter elements of first array: “. i<MN. } else{ while(b>=0) C[c++] = B[b--].) { if(A[a]<=B[b]) C[c++] = A[a++].M. C[50]. . a<m && b>=0.

q.j<q. i<m.} ASSIGNMENT-15 Q.n. Write a program to enter two matrices & to print the sum of these two matrices ANS.h> void main() { int A[50][50].i++) {for(int j=0.j++) { C[i][j]=A[i][j]+B[i][j]. if(m == p && n == q) { cout<<”Enter elements of second matric:\n”.} cout<<”\n\nSum of both matrices is:\n”. of rows and columns of second matric: “. cout<<”Enter the no. cin>>p>>q. B[50][50]. i++) {for(int j=0. for(i=0. of rows and columns of first matrix: ”. cin>>m>>n. j++) cin>>A[i][j]. } . }cout<<endl.j<n. cout<<C[i][j]<<” “.p. for(i=0.} cout<<”\n\nEnter the no. j<n. cout<<”Enter elements of first matrix:\n”.m. Required program should be: #include<iostream. } } else cout<<”\n\nBoth matrices should be of same size!!”.i<p.j++) cin>>B[i][j].i++) { for(int j=0.i<m. C[50][50]. for(int i=0.

for(int i = 1.h> #include<limits.i++) cout<<AR[i]. while(t<AR[j]) {AR[j] = AR[j+1].h> void InsSort(int AR[].i++) cin>>AR[i]. for(i = 1.Write a program for insertion sort.i<=N. for(int i = 1. i<=n. cout<<”Enter the length of array: “. AR[0] = INT_MIN. j = i-1. i++) { t = AR[i]. cin>>N. N. Required program should be: #include<iostream.i<=N. InsSort(AR. cout<<”Enter Array elemnts:\n”.ASSIGNMENT-16 Q.N). cout<<”\n\nThe Sorted array is:\n”. j--. } . ANS. } } void main() { int AR[50].} AR[j] = t. int n) { int t. j.

for(int i = 0. SelSort(AR. j<n. ANS. int n) { int s.ASSIGNMENT-17 Q. i<n. t. AR[p] = t. for(i = 0. for(int j = i+1. for(int i = 0. i<N. Required program should be: #include<iostream. cout<<”\n\nSorted array is:\n”. p = j.} } t = AR[i]. i<N. N).Write a program for selection sort. cin>>N. cout<< “Enter the length of the array: “. i++) . p. } } void main() { int AR[50].h> void SelSort(int AR[]. j++) { if(AR[j]<s) {s = AR[j]. cout<<”Enter array elements: “. i++) cin>>AR[i]. N. AR[i] = AR[p]. i++) { s = AR[0].

h> #include<conio.\tExit\nEnter your option: “.cout<<AR[i]<<’ ‘. void main() { int opt.*newptr.\tInsert node at beginning\n2. cout<<”3. ANS. Node * next. cin>>opt. void Insert _End(Node *). Node * Create_New_Node(int). char ch = ‘y’. void Insert _Beg(Node *).Write a program to insert a node at beginning and end of a link list. *rear. option: clrscr().h> #include<process. int inf.\tInsert node at end\n”. cout<<”What do you want to do?\n1. void Display(Node *). *save. Required program should be: #include<iostream. *ptr. } *start. } ASSIGNMENT-18 Q.h> struct Node{ int info. switch(opt) { case 1: start=NULL. while(ch == ‘y’ | | ch ==’Y’) .

cout<<”Enter information for the new node: “. cin>>ch. getch(). Insert_Beg(newptr). getch(). while(ch == ‘y’ | | ch == ‘Y’) { clrscr(). newptr = Create_New_Node(inf). Display(start).} else { cout<<”Cannout create new node!! Aborting…. cout<<”Creating new node!!\n\n”. cin>>inf. N to exit…\n”. exit(1).{ clrscr(). exit(1). if(newptr != NULL) { cout<<”New node created successfully!!”. int inf. } cout<<”\n\nNow inserting this node in the end of the . if(newptr != NULL) { cout<<”New node created successfully!!”. cout<<”Creating new node!!\n\n”. cout<<”\nNow the list is:\n”. char ch = ‘y’.!!”.!!”. cin>>inf. }goto option. cout<<”Press Y to enter more nodes. newptr = Create_New_Node(inf). case 2: start = rear = NULL.} else { cout<<”Cannout create new node!! Aborting…. cout<<”Enter information for the new node: “. } cout<<”\n\nNow inserting this node in the beginning of the list!”.

else { save = start. }goto option. N to exit…\n”. ptr -> info = n. . rear = np. ptr->next=NULL. exit(0). cout<<”\nNow the list is:\n”. Insert_End(newptr). getch(). } } Node * Create_New_Node(int n) { ptr = new Node. case 3: cout<<”Byee!!”. return ptrl } void Insert_Beg(Node * np) { if(start == NULL) start = np. } } void Inster_End(Node * np) { if(start == NULL) start = rear = np. cout<<”Press Y to enter more nodes. cin>>ch. goto option.list!”. else { rear -> next = np. getch(). start = np. Display(start). np->next=save. default:cout<<”Wrong option!!!!”. } } void Display(Node * np) { while(np != NULL) { cout<<np -> info <<” -> “.

Node * next.h> struct Node { int info. int inf. *ptr.Write a program to delete a node from the beginning of a link list ANS. *rear. if(newptr = NULL) . *save. Node * Create_New_Node(int). Required program should be: #include<iostream. } cout<<”!!!\n”. void Insert(Node *). cout<<”\nEnter information for the new node: “. void Display(Node *).h> #include<process. cin>>inf. char ch = ‘y’. *newptr. } ASSIGNMENT-19 Q. while(ch == ‘y’ | | ch== ‘Y’) { clrscr().np=np -> next.h> #include<conio. void main( ) { start = rear = NULL. newptr = Create_New_Node(inf). void Del Node( ). } *start.

np = np -> next. ptr -> info = n.{ cout<<”\nCannot create new node!!”. }while(ch == ‘y’ | | ch == ‘Y’). else {ptr = start. Display(start). } Node * Create_New_Node(int n) { ptr = new Node. do { cout<<”\nThe list now is:\n”. } clrscr(). . cin>>ch. ptr->next=NULL. N to exit”. else {rear -> next = np.} Insert(newptr) cout<<”\nPress Y to enter mode nodes. } void Insert(Node * np) { if(start == NULL) start = rear = np.} } void DelNode() { if(start == NULL) cout<<”UNDERFLOW!!!\n”. delete ptr. getch(). Rear=np. cout<<”Want to delete first node? (y/n): “.} cout<<”!!!\n”.} } void Display(Node * np) { while(np != NULL) { cout<<np -> info <<”->”. return ptr.start=start->next. exit(1). if(ch == ‘y’ | | ch == ‘Y’) DelNode(). getch().

} ASSIGNMENT-20 Q. int inf. void main() { start = rear = NULL. cin>>inf. *save. cout<<”\nPress Y to enter more nodes.} Insert(newptr). Node * Create New Node(int). ANS.h> #include<process. *rear. void Insert(Node *). char ch = ‘y’. Node * next. if(newptr == NULL) { cout<<”\nCannot create new node!!!”. newptr = Create_New_Node(inf). while(ch == ‘y’ || ch == ‘Y’) { cout<<”\nEnter information of the node: “. N to exit: “. exit(1). Required program should be: #include<iostream. } *start. void Traversal(Node *). .h> struct Node { int info. Write a program for traversal in a link list.*newptr. *ptr.

} Node * Create_New_Node(int n) { ptr = new Node. } cout<<”!!!\n”. else { rear -> next = np. } cout<<”\nThe list is now:\n”. ptr->next=null. } void Insert(Node * np) { if(start = NULL) start = rear = np. Traversal(start). ptr -> info = n. Rear=np. } . return ptr.cin>>ch. np = np -> next.} } void Traversal(Node * np) { while(np != NULL) { cout<<np -> info<<” -> “.

. *save. Required program should be: #include<iostream. char ch = ‘y’. int inf. if(newptr == NULL) { cout<<”\nCannot create new node!!!”.h> #include<process.h> struct Node { int info. void Insert_End(Node *). Node * next. } *front. while(ch == ‘y’ || ch == ‘Y’) { cout<<”\nEnter information for the new node: “. void Display(Node *). Write a program for insertion in linked queue ANS. newptr = Create_New_Node(inf). *rear. Node * Create_New_Node(int). cin>>inf. void main() { front = rear = NULL.ASSIGNMENT-21 Q. *newptr. exit(1)} Insert_End(newptr). *ptr.

N to exit…: “.} } void Display(Node * np) { while(np != NULL) { cout<<np -> info<<” -> “. rear=np. ptr->next=null. np = np -> next. } void Insert_End(Node * np) { if(front == NULL) front = rear = np. cout<<”\nPress Y to enter more nodes. } } Node * Create_New_Node(int n) { ptr = new Node. cin>>ch. return prt. ptr -> info = n. } . } cout<<”!!!\n”. Display(front).cout<<”\nNow the Queue(Front…to…Rear) is:\n”. else { rear -> next = np.

} *front. ANS. *save. void main() { front = rear = NULL.h> #include<conio. void DelNode_Q(). void Insert(Node *).ASSIGNMENT-22 Q. *ptr. void Display(Node *). *rear. Node * next.h> struct Node { int info. if(newptr == NULL) . char ch = ‘y’. Write a program for deletion in linked queue. Node * Create New Node(int). newptr = Create_New_Node(inf). cin>>inf. Required program should be: #include<iostream. while(ch == ‘y’ || ch == ‘Y’) { cout<<”\nEnter information for the new node: “. int inf.*newptr.h> #include<process.

do { cout<<”\nThe Linked-Queue now is (Front…to… Rear):\n”. cout<<”Want to delete first node? (y/n)…: “. else { ptr = front. delete ptr. ptr-> next=NULL. cin>>ch. Display(front). N to exit…: “. } clrscr(). front = front -> rear.{ cout<<”\nCannot create new node!!!”. } Void Insert(Node * np) { if(front == NULL) front = rear = np. cout<<”\nPress Y to enter more nodes. cin>>ch. exit(1)} Insert(newptr). if(ch == ‘y’ || ch == ‘Y’) DelNode_Q(). ptr -> info = n. else { rear -> next = np. }while(ch == ‘y’ || ch == ‘Y’).} } Void DelNode_Q() { if(front == NULL) cout<<”UNDERFLOW!!!\n”. } Node * Create_New_Node(int n) { ptr = new Node. } } Void Display(Node * np) { while(np != NULL) . rear =np. return prt.

num. for (i = 0. cout << "Enter the location to insert in array : ". i < N. np = np -> next. cin >> N. } cout<<”!!!\n”. cin >> range[i]. Write a program for array insertion. prev. N. . Required program should be: #include <iostream. cin >> num.h> #include <conio. ". } cout << "Enter the inserted value : ". ASSIGNMENT-23 Q. cout << "Enter the length of your array : ".} { cout<<np -> info<<” -> “.h> void main() { clrscr(). ANS. i. i++) { cout << "Value " << i + 1 << ". clrscr(). int range[100]. loc. cout << "Enter the array values \n".

} else cout << "Your location is not in the array range". N = N + 1.1. i++) cout << range[i] << endl. i < N. getch(). cout << "\n". } range[prev] = num. while (prev >= loc) { range[prev] = range[prev-1].cin >> loc. } . cout << "The resulted output is :\n". for (i = 0. if (loc <= N) { prev = N. prev = prev .

loc. num. int range[100]. cin >> N.h> #include <conio. i < N. ANS. Required program should be: #include <iostream.ASSIGNMENT-24 Q. i. } cout << "Enter the location to delete from the array : ". for (i = 0. N. prev. Write a program for array deletion. cin >> range[i]. ".h> void main() { clrscr(). cout << "Enter the length of your array : ". cout << "Enter the array values \n". clrscr(). i++) { cout << "Value " << i + 1 << ". .

cin >> loc.1. loc = loc . } . cout << "\n". } N = N . i < N. prev = loc. for (i = 0. cout << "\nThe deleted value is : " << num. prev = prev + 1. while (prev < N) { range[prev] = range[prev + 1]. i++) cout << range[i] << endl. // Decrease the length of array by 1. cout << "The resulted output is :\n".1. } else cout << "Your location is not in the array range to delete". if (loc < N) { num = range[loc]. getch().

cout<<”\nEnter array elements:\n“. N. i<N.. cout<<”\nArray with doubled elements is as follows. i++) { AR[i]*=2.ASSIGNMENT-25 Q. ANS. Write a program for array traversal.} cout<<endl. cout<<AR[i]<<’ ‘. i<N. i++) cin>>AR[i]. Required program should be: #include<iostream. cin>>N.): “.\n”. cout<<”Enter length of array (Max 50.h> void main() { int AR[50]. . for(int i=0. for(i=0.

} ASSIGNMENT-26 Q. New Delhi Palmvenue MU15 R Kohli 5/A. Mumbai Westend . ABC New Delhi Enclave ND02 Amit Kumar 12. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii).SouthStre Mumbai et MU50 S Kaur 27-K. Consider the following tables Consignor and Consignee. Table: CONSIGNOR CnorID CnorName CnorAddres City s ND01 R Singhal 24.

B. i) SELECT Cnor Name FROM Consignor WHERE City = “Mumbai”. CneeAddress FROM Consignee WHERE CneeCity NOT IN (‘Mumbai’. CneeName. (viii) SELECT CneeID.P.Table: CONSIGNEE CneeID CnorID CneeNam CneeAddress e MU05 ND01 Rahul 51Park Avenue Kishore ND08 ND02 P Dhingra 16/JMoore Enclave CO19 MU15 A. (iv) To display number of consignors from each city. ANSWERS. (iii) To display consignee details in ascending order of CneeName.CneeName FROM Consignor A. ‘Kolkata’).CnorName. Ray 2ACentral Avenue MU32 ND02 S Mittal P 245. CnorName.CneeCity=’Mumbai’. CnorAddress. CneeName FROM Consignee WHERE CnorID=’MU15’ OR CnorID=’ND01’. AB Colony ND48 MU50 B.P. (vi) SELECT A.CnorID AND B. (ii) To display the CneeID. Consignee B WHERE A. CneeAddress for every Consignee. (v) SELECT DISTINCT City FROM Consignee.CnorID=B. . Jain B Block D. A Vihar CneeCit y Mumbai New Delhi Kolkata Mumbai New Delhi (i) To display the names of all Consignors form Mumbai. (vii) SELECT CneeName.

CneeName.SELECT CneeID. Consider the following tables Consignor and Consignee. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii). CneeAddress FROM Consignee A. CnorName. A Vihar CneeName Rahul Kishore A.CnorID. Count(Cneecity) FROM Consignee GROUP BY CneeCity v) CneeCit y Mumbai New Delhi Kolkata CnorName CneeName vi) R Singhal Rahul Kishore Amit Kumar S Mittal vii) CneeName CneeAddress ii) P Dhingra B.P. Consignor B WHERE Consignor. Roy viii) ASSIGNMENT-27 Q. iii) SELECT * FROM Consignee ORDER BY CneeName ASC.P.CnorID =Consignee.Block D. iv) SELECT CneeCity. Table: Product P_ID TP01 FW05 ProductName Talcum Powder Face Wash Manufacturer LAK ABC Price 40 45 .cnoraddress. Jain CneeID MU05 KO19 16/JMoore Enclave 13.

(viii) SELECT ProductName. City. iii) SELECT ClientName. ii) SELECT * FROM Product WHERE Price BETWEEN 50 to 100. (vi) SELECT Manufacturer. ProductName FROM Product. (vii) SELECT ClientName. City from table Client. MAX(Price). i) . SELECT * FROM Client WHERE City= “Delhi”. (ii) To display the details of Products whose Price is in the range of 50 to 100 (Both values included). (iv) To increase the Price of all Products by 10. Client WHERE Client.P_ID. Product WHERE Client P_ID = Product P_ID. Count(*) FROM Product GROUP BY Manufacturer. (v) SELECT DISTINCT City FROM Client. ProductName. Price FROM Client.P_ID = Product. (iii) To display the ClientName. Price*4 FROM Product. ANSWERS. with their corresponding matching P_ID. and ProductName and Price from table Product. Min(Price).BS01 SH06 W12 Bath Soap Shampoo F Face Wash ABC XYZ XYZ 55 120 95 Table: Client C_ID 01 06 12 15 16 ClientName Cosmetic Shop Total Health Live Life Pretty Woman Dreams City Delhi Mumbai Delhi Delhi Bangalore P_ID FW05 BS01 SH06 FW12 TP01 (i) To display the details of those Clients whose City is Delhi.

iv) UPDATE Product SET Price = Price + 10. v) City Delhi Mumbai Banglor e Manufactur MAX(Pric er e) LAK 40 ABC XYZ 55 120 MIN(Price Count ) 40 1 45 95 2 2 vi) ClientName Cosmetic Shop Total Health Live Life Pretty Woman Dreams vii) ProductName Face Wash Bath Soap Shampoo Face Wash Talcum Powder .

ProductName Talcum Powder Face Wash Bath Soap Shampoo Face Wash viii) Price 160 180 220 480 380 .