Monday, 16 October 2017

SQL WORKSHEET 2017-18

SQL WORKSHEET 2017-1888
                             computer Science


1)
Observe the following STUDENTS and EVENTS tables carefully and write the
name of the RDBMS operation which will be used to produce the output as shown in LIST. Also, find the Degree and Cardinality of the LIST.



2)
Answer the following questions:
a)
Expand the following:
(i) SQL (ii) DBMS
b)
What is relational database model?
c)
What are all the numeric data types possible in sql?
d)
Differentiate between char and varchar.
3)
Define the following keys:
a)Primary key  b) Candidate key  c)Alternate key
4)
Write any two advantages of SQL.
5)
Differentiate between
a)Union and Cartesian product
b)DDL and DML commands
6)
Answer the following questions:
a)
Ms. Ravina is using a table 'customer' with custno, name, address and phonenumber. She needs to display name of the customers, whose name start with letter 'S'. She wrote the following command, which did not give the result.
Select * from customer where name="S%";
Help Ms. Ravina to run the query by removing the errors and write the correct query.
b)
Write SQL query to add a column totalprice with data type numeric and size 10, 2 in a table product.


c)


The name column of a table 'student' is given below.











Based on the information, find the output of the following queries:
Select name from student where name like "%a";


d)
Sonal needs to display name of teachers, who have "o" as the third character in their name. She wrote the following query.
Select name from teacher Where name ="$$o?";
But the query is not producing the result. Identify the problems and correct it.
e)
Deepak wants to remove all rows from the table Bank. But he needs to maintain the structure of the table. Which command is used to implement the same?
7)
In a database there are two tables - 'Brand' and 'Item' as shown below:


Write MYSQL queries for the following:
a) To display Iname, price and corresponding Brand name (Bname) of those items, whose price is between 25000 and 30000 both values inclusive).
b)  To display ICode, Price and BName of the item, which has IName as "Television".
c) To increase the Prices of all those items by Rs 10% which have a brand name.
d) To add a column qty of numeric type to ITEM table.
e)To remove those records from ITEM table whose INAME start with the letter ‘C’.
8)





9)









Write SQL queries for (i) to (iv) and find outputs for SQL queries (v)to (viii), which are based on the tables.




(i) To display all details from the table MEMBER in descending order of ISSUEDATE.
(ii) To display the DCODE and DTITLE of all Folk Type DVDs from the table DVD.
(iii) To display the DTYPE and number of DVDs in each DTYPE from the table DVD.
(iv) To display all NAME and ISSUEDATE of those members from the table MEMBER who have DVDs issued (i.e., ISSUEDATE) in the year 2017.
(v) SELECT MIN(ISSUEDATE) FROM MEMBER;
(vi) SELECT DISTINCT DTYPE FROM DVD;
(vii) SELECT D.DCODE, NAME, DTITLE FROM DVD D, MEMBER M WHERE D.DCODE=M.DCODE;
(viii) SELECT DTITLE FROM DVD WHERE DTYPE NOT IN("Folk", "Classical");
10)
Create a table STUDENT with the following fields.
AdmNo   integer , Name  20 characters ,  Class  integer, AvgMks   numeric,
Grade   character, Dateofadm      Date
Ensure that the following constraints are met
  • AdmNo is the Primary Key
  • Default value of avg is zero
  • Class should be 9, 10, 11 or 12
Default value of Grade is NULL
11)
Insert AdmNo, name, class, AvgMks and Dateofadm of the students in the table as given below

AdmNo
Name
Class
AvgMks
Grade
Dateofadm
1289
Avinash G
11
67.8

2004-06-12
1378
Akshay Kumar
12
54.9

2007-06-20

The End

Monday, 18 September 2017

Pointers WS - 2016

CHENNAI PUBLIC SCHOOL, ANNANAGAR
COMPUTER SCIENCE - CLASS XII WORKSHEET TOPIC : POINTERS

1)  Predict the output for the following code:



a)    #include <iostream.h>
void main()
{int *Queen,Moves[]={11,22,33,44};
Queen = Moves;
Moves[2]+=22;
cout<<"Queen@"<<endl;
*Queen-=11;
Queen+=2;<<"Next @"<<*Queen<<endl;
Queen++;
cout<<"Finally@"<<*Queen<<endl;
cout<<"New Origin @"<<Moves[0]<<endl;}

b)    #include <iostream.h>
#include <string.h>
void FUN(char *str)
{
int L,i,j;
L=strlen(str);
for(i=90;i>=65;i--)
for(j=0;j<L;j++)
if(str[j]==char(i)||str[j]==char(i+32))
cout<<str[j];
cout<<endl;
}
void main()
{
char *p="Christmas-2016";
FUN(p);
}

c) #include<iostream.h>
void main()
{int A[]={10,15,20,25,30};
int *p=A;
while(*p<30)
{
        if (*p%3!=0)
          *p=*p+2;
        else
          *p=*p+1;
        p++;}
for(int j=0;j<=4;++j)
{
  cout<<A[j]<<"*";
  if (j%3==0) cout<<endl;
}
cout<<A[4]*3<<endl;
}

d)          #include<iostream.h>
void main()
{int Numbers[]={2,4,8,10};
int *ptr=Numbers;
for(int c=0;c<3;++c)
{  cout<<*ptr<<"@";
  ptr++;}
cout<<endl;
for(c=0;c<4;c++)
{  (*ptr)*=2;
  --ptr;}
for(c=0;c<4;c++)
 cout<<Numbers[c]<<"#";
cout<<endl;}

e) #include <iostream.h>
#include <ctype.h>
#include <conio.h>
#include <string.h>
void PointersFun(char text[],int &count)
{
char *ptr=text;
int length=strlen(text);
for(;count<length-2;count+=2,ptr++)

{
*(ptr+count)=toupper(*(ptr+count));
}}
void main()
{
clrscr();
int position=0;
char data[]="ChangeString";
PointersFun(data,position);
cout<<data<<"@"<<position;
cout.write(data+3,4);
}
f) #include <iostream.h>

void main()
{char *Text=²AJANTA²;
int *P, Num[]={1,5,7,9};
P=Num;
cout<<*P<<Text<<endl;
Text++;
P++;
cout<<*P<<Text<<endl;
}
g) #include <iostream.h>
#include <string.h>
#include <conio.h>
char * MyFunction(char RECEIVE_TEXT[])
{
RECEIVE_TEXT+=5;
cout<<*RECEIVE_TEXT<<" "<<strlen(RECEIVE_TEXT)<<endl;
return RECEIVE_TEXT;
}
void main()
{
char *SAMPLETEXT="IMAGINATION";
cout<<MyFunction(SAMPLETEXT)<<endl;
SAMPLETEXT++;
*SAMPLETEXT=*SAMPLETEXT+3;
cout<<SAMPLETEXT;}



h) #include <iostream.h>
  void main()
  {
  int a=32,*ptr=&a;
  char ch=’A’.&cho=ch;
  cho+=a;*ptr+=ch;
  cout<<a<<” “<<ch<<endl;
  }

i) Distinguish between
     int *ptr=new int(5);
     int *ptr=new int[5];

j) What are the operators associated with pointer variable? Explain with example.

k) Illustrate the  use of “self-referential structures” with the help of an example.


 l) Differentiate between static and dynamic allocation of memory.

Classes and Objects - Constructors and Destructors - Function Overloading WS - key












Classes and Objects - Constructors and Destructors - Function Overloading WS