For All Human Beings.......

Friday, November 30, 2007

Boolean Algebra (Basic Concepts)

Dear Students
  • I have created another Mind Map On Boolean Algebra (Basic Concepts) as I am finding this tool very interesting, easy to work with and very useful in developing the topic. This tool is allowing me to discuss all the relevant points in depth and still maintaining the connectivity with the main topic. I would like to know your views about this tool.

SQL(Structured Query Language)

  • I have created Mind Map on the topic 'SQL' Using Open Source Software FreeMind. I think my students will find it beneficial while preparing and revising this topic.
  • To access the Mind Map Click Here.......

Monday, November 26, 2007

Database Concepts : Mind Map

FreeMind Mind Map
  • I have created this Mind Map to facilitate Organized learning and revision of the topic-'Database Concepts'.
  • I have published my work for sharing on freemindshare.com
  • The URL for this particular Mind Map is:
http://freemindshare.com/map/iq29ILNSUV/



Sunday, November 25, 2007

Database Concepts

Following concepts are covered in the following presentation:
  • Concept of Domain
  • Tuple
  • Relation
  • Primary Key, Alternate Key, Candidate key
Relational Algebra
  • Selection
  • Projection
  • Union
  • Cartesian Product


Answers : MCQ-12/02


The OMR answer sheet with correct answers marked is as follows:

Thursday, November 22, 2007

MCQ-12/02

Attempt this MCQ. I will post its answers after 2 days

Kulachi Hansraj Model School

Multiple Choice Questioner

(General Concepts, Header Files, File Handling)

Class XII

Time : 15 min. M.Marks : 30

1. When working with character arrays, always reserve enough array elements to hold the string AND its null-terminating character (\0).

[a] True [b] False

2. In C++, 14 % 4 =

[a] 1 [b] 2 [c] 3 [d] 4

3. Variables that are declared, but not initialized, contain
[a] blank spaces
[b] zeros [c] "garbage" values [d] nothing - they are empty

4. Array indexing always starts with the number
[a] 0 [b] 1 [c] 2 [d] \0

5. A character variable may contain up to seven letters.

[a] True [b] False

6. All strings end with a null zero in memory.

[a] True [b] False

7. The name of a variable is known as its

[a] identifier [b] constant

[c] data type [d] base

8. In C++, the % refers to

[a] percentages [b] modulus operator

[c] division [d] data storage

9. A variable is given a value through

[a] osmosis [b] the cout statement

[c] the header file [d] an assignment statement

10. Variable names may begin with a number.

[a] True [b] False

11. When a data type must contain decimal numbers, assign the type

[a] int [b] char [c] double [d] long int

12. Mathematicians and computers interpret the equal sign (=) in the same way.

[a] True [b] False

13. setprecision requires the header file

[a] stdlib.h [b] iomanip.h [c] console.h [d] conio.h

14. The following statement is valid. double price = 7,450.98;

[a] True [b] False

15. All variables must be declared before they can be used.

[a] True [b] False

16. Character literals always have a length of one.

[a] True [b] False

17. If char catname[15]; , which of the following is valid?

[a] catname[15] = "Millie"; [b] catname = "Millie";

[c] catname[ ] = "Millie"; [d] none are valid

18. Which type of data file is analogous to an audio cassette tape?

[a] random access file [b] sequential access file

[c] binary file [d] source code file

19. Which of the following header files is required for creating and reading data files?

[a] ofstream.h [b] fstream.h

[c] ifstream.h [d] console.h

20. If you create a file with the same name as an existing file, you will be prompted to rename your new file.

[a] True [b] False

21. In the code fout.open("scores.dat", ios::out);

[a] ios::out is the stream operation mode.

[b] fout is the header file reference.

[c] ios::out is the stream variable name..

[d] fout is the name of the file.

22. A text editor can be used to view, or create, a file.

[a] True [b] False

23. What header file contains C++ file I/O instructions?
[a] iostream.h [b] fstream.h

[c] infstream.h [d] outstream.h

24. ifstream fin; would be used when

[a] creating a file [b] reading a file

[c] appending a file [d] removing a file

25. eof( ) is the function used for

[a] asserting no errors in a file [b] appending data to a file

[c] counting the amount of data in a file [d] checking for end of file

26. If a file you are opening for appending does not exist, the operating system will detect the missing file and terminate the operation.

[a] True [b] False

27. It is possible to open several files for access at the same time.

[a] True [b] False

28. Which of the following is not a valid ofstream argument?
[a] ios::app [b] ios::trunc
[c] ios::noreplace [d] ios::create

29. What does ios::ate mean as an argument to ofstream?
[a] Open file, but do not create. [b]Open file, create.
[c] Open file for read access only.[d]Open file, set the position to the end.

30. How would you output to an open file named a_file?
[a] a_file.out("Output"); [b] a_file="Output";
[c] a_file<<"Output"; [d]a_file.printf("Output");

Wednesday, November 21, 2007

Linked Queue : C++ Code

Struct NODE
{
int Data;
NODE *Next;
};

class Queue
{
NODE *Rear,*Front;

public:
Queue(){Rear=NULL;Front=NULL;}
Void Qinsert();
Void Qdelete();
Void Qdisplay();
~Queue();
};

_______________________________________________________________

void Queue::Qinsert()
{
NODE *Temp;
Temp=new NODE;
Cout<<”Data:”;
Cin>>Temp->Data;
Temp->Next=NULL;
If (Rear==NULL)
{
Rear=Temp;
Front=Temp;
}
else
{
Rear->Next=Temp;
Rear=Temp;
}
}

_______________________________________________________________

void Queue::Qdelete()
{
if (Front!=NULL)
{
NODE *Temp=Front;
Cout<<<”deleted/n”;
Front=Front->Next;
Delete Temp;
If (Front==NULL) Rear=NULL;
}
else
cout<<”Queue Empty..”;
}

_______________________________________________________________

void Queue::Qdisplay()
{
NODE *Temp=Front;
While(Temp!=NULL)
{
cout<
<Temp->Data;
Temp=Temp->Next;
}
}

_______________________________________________________________

void Queue::~Queue()//Destructer Function
{
while (Front!=NULL)
{
NODE *Temp=Front;
Front=Front->Next;
delete Temp;
}
}

_______________________________________________________________

void main()
{
Queue QU; char Ch;
do
{ … // Complete the main function

}while (Ch!=’Q’);
}

_______________________________________________________________

Tuesday, November 20, 2007

Linked Stack : c++ code

struct NODE
{
int Data;
NODE *link;

};

class LStack
{
NODE *Top;

Public:
LStack(){Top=NULL;}
void Push();
void Pop();
void show_stack();
~LStack();
};

void LStack::Push()
{
NODE * ptr;
ptr=new NODE;
cout<<”Data:”;
cin>>ptr->Data;
ptr->link=Top;
Top=ptr;
}

void LStack::Pop()
{
if (Top!=NULL)
{
NODE *Temp=Top;
Cout<<”deleted../n”;
Top=Top->link;
delete Temp;
}
else
cout<<”Stack Empty..”;

}

void LStack::show_stack()
{
NODE *Temp=Top;
while(Temp!=NULL)
{
cout<
<Temp->Data;
Temp=Temp->link;
}
}

void LStack::~LStack() //Destructer Function
{
while (Top!=NULL)
{
NODE *Temp=Top;
Top=Top->Next;
delete Temp;
}
}

void main()
{
Stack ST; char Ch;
do
{
cout<<”P/O/D/Q”;cin>>Ch;
switch (Ch)
{
case ’P’:ST.Push();break;
case ’O’:ST.Pop();break;
case ’D’:ST.
show_stack();
}
}
while (Ch!=’Q’);

} // Destructor function will be called

// automatically when the scope of the

// object gets over

Monday, November 19, 2007

Stacks and Queues

I am going to post a presentation on Stacks(Static and Dynamic) and Queues.
Hope it will help in adding clarity.

Pointers in C++

I am posting a presentation on pointers, hope it will clarify the concepts....
  1. What is pointer
  2. value at (*) and Address of (&) operators associated with pointer variables
  3. Static and Dynamic Memory allocation
  4. use of new operator
  5. Use of delete operator
  6. Free Storage pool
  7. Memory leaks

Sunday, November 18, 2007

Pointers and Dynamic memory allocation

Tomorrow I will be sharing with you the concepts related to pointers and Dynamic memory allocation ......

Copy constructor

What is copy constructor? Discuss two situations when a copy constructor is automatically invoked giving appropriate examples.

Copy constructor is

  • a constructor function (Function with the same name as the class)
  • used to make deep copy of objects.

There are 3 important places where a copy constructor is called.

  1. When an object is created from another object of the same type
  2. When an object is passed by value as a parameter to a function
  3. When an object is returned from a function

If a copy constructor is not defined in a class, the compiler itself defines one. This will ensure a shallow copy. If the class does not have pointer variables with dynamically allocated memory, then one need not worry about defining a copy constructor. It can be left to the compiler's discretion.

But if the class has pointer variables and has some dynamic memory allocations, then it is a must to have a copy constructor. (Find its example in BLUE colour)

For ex:
class A //Without copy constructor

{ private:
int x;
public:
A() {A = 10;}
~A() { }
};


class B //************** With copy constructor ************
{
private:
int month;
public:
B( int y) //********* Parameterized constructor ***********
{
month = y;
}
~B( )
{
cout << "destructor function invoked"; }

B( B &b) //*************** Copy constructor *************
{
month = b.month;
}

};


class B //With copy constructor
{
private:
char *name;
public:
B()
{
name = new char[20];
}
~B()
{
delete name[];
}
//Copy constructor
B(B &b)
{
name = new char[20];
strcpy(name, b.name);
}
};


Example : When an object is created from another object of the same type

class A
{ int a;
public:
A(int x )
{ cout <<"Constructor invoked ..."; a=x; } }Obj1(23); A Obj2=Obj1; }


Example :
1.
When an object is passed by value as a parameter to a function
2.
When an object is returned from a function


class time

{ int hr;
int min;
public:
time ( ) // ******** constructor function ********
{ hr = min = 0;}
void gettime(int x,int y) {hr=x;min=y;}
void showtime( ) { cout <<" : " <<<"\n";} };

time addtime( time T1, time T2)
{ time T3;
T3.hr =
T1.hr + T2.hr;
T3.min = T1.min + T2.min;
if (T3.min >= 60)
{ T3.min =T3.min - 60;
T3.hr = T3.hr+1;
}
return T3;
}

void main( )
{ time X1 (5,45); // Parameterized constructor Invoked
time X2 (7,40); // Parameterized constructor Invoked
time X3=addtime(X1,X2); // Copy Constructor invoked
X3.showtime( ); // This will show the time as 13 : 25
}