CS201SolvedFinalTermPaperswww.vuattach.ning.com1
CS201SolvedFinalTermPaperswww.vuattach.ning.com1
COM
FINALTERM EXAMINATION
Fall 2009
CS201- Introduction to Programming
► 0000128
► 0128128
► 1280000
► 0012800
default alignment is from left due to this it first prints 4 Zeros(setw=7, digit=3 i.e 1-2-8,) 7-3=4 Zeros vuzs
Also note that the new operator returns a void pointer. Any new operator
we write must have this parameter and return type.
► Zero
► One
► Two
► Three
The function arguments must contain at least one generic data type. P#
499
Let suppose
int a, b, c, d, e;
a = b = c = d = e = 42;
This can be interpreted by the complier as:
► a = (b = (c = (d = (e = 42))));
► (a = b = (c = (d = (e = 42))));
► a = b = (c = (d = (e = 42)));
► (a = b) = (c = d) = (e = 42);
a = (b = (c = (d = (e = 42) ) ) );
► 0 to 8
► 1 to 8
When 6 divides any number, the remainder will always be less than 6.
Ther
result will be between therefore we will add 1. 1 + rand ( ) % 6;
Which of the following is the correct function call having array named
student of 10 elements as a parameter.
► addRecord(student[]) ;
► addRecord(student) ;
► addRecord(student[10]) ;
► addRecord(*student) ;
when we pass array we don’t give limit of array
Example:
Pass array to function
#include<stdio.h>
#include<conio.h>
void read(int *,int);
void dis(int *,int);
void main()
{
int a[5],b[5],c[5],i;
► False
An 'Identifier' means any name that the user creates in his/her program.
These names can be of variables, functions and labels
Once the static variables are created, they exist for the life of the
program. They do not die.
The truth tables are very important. These are still a tool available for
analyzing logical expressions.
( Marks: 1 )
What does getline() member function of cin stream do?
(p) ;
It will not delete the p rather, it will send the memory gotten and pointed
by p back to the free store.
( Marks: 2 )
What will be the output of following code, if user input a number 123?
int input ;
cin >> oct >> input;
cout << hex << input ;
( Marks: 2
HTTP://VUATTACH.NING.COM
( Marks: 3 )
When we call calloc function to allocate memory and its return
a NULL pointer what does it mean?
Calloc function takes two arguments. The first argument is the required
space in terms of numbers while the second one is the size of the space
Now we have to see what happens when either we ask for too much
memory at a time of non-availability of enough memory on the heap or
we ask for memory that is available on the heap , but not available as a
single chunk?. In this case, the call to calloc will fail. When a call to
memory allocation functions fails, it returns a NULL pointer.
( Marks: 3 )
Read the given code and explain code functionality.
JAVA gives the concept of garbage collection with the use of references.
Due to this garbage collection, we are free from the headache of de-
allocating the memory. We allocate and use the memory. When it is no
longer in use, JAVA automatically deletes (frees) it through garbage
collection But in C and C++ languages, we have to take care of de-
allocating the memory. In classes where we use dynamic memory, we
have to provide destructors to free this memory. The languages keep
evolving, new constructs will keep evolving in existing or new languages.
( Marks: 5 )
Write a simple program using the get() member function of cin object
reading a text of 30 characters from the keyboard, store them in an
array and then using put() member function of cout object to display
them on the screen.
( Marks: 10 )