CS201 VU Midterm Papers Spring May 2012

Q1.write the code to perform the following tasks

a. Declare a 2D array of integers having two rows and three columns.
b.declare a pointer and point it to the above declared array.
Q2.suppose there is structure named STUDENT and we wish to evaluate the size of this structure, Hoe it can be accomplished in C++?
Q3.write the program which declares and initialize an array of 10 integers and then displays the 4th and 8th element of the array by using a pointer?
Q.4. if any programming language structures and arrays are tools for collecting things having some common properties what is main difference between a structure and an array? Q5.we can use a pointer to character or an array of characters to store a string in C/C++which one the mentioned approaches is the most suitable approach for storing the string and why?

Q.6.Explain the logic of given program and write down its output
#include <iostream.h>
#include <string.h>
int main ()
char str [] =” This is a line.”
p = strctr(str,’s’);
while (p!=Null) {
cout ”found at n”p-str+1>>
P=strctr (p+1,’s’);
Return 0;