ExaMail


Question 1

Briefly explain the following concept (10 )
a. Object Oriented Programming
b. Class
c. Inheritance
d. Data Encapsulation
e. Polymorphism

Question 2

Indicate the header files required for the following library functions (5)
a. setw()
b. sqrt()
c. getch()
d. isnum()
e. strlen()

Question 3

Write a function to multiply two 8x8 integer matrices. Matrices A[8][8], B[8][8] and C[8][8] will be passed to the function and the function should compute C = AxB. The prototype of the function is given below (5)


void Multiply(int A[8][8], int B[8][8], int c[8][8]);

Question 4

Write a program to print the following output
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

Question 5

Write a program to check whether the string specified by the user is a palindrome. (5)

Question 6

Write a function to find the first 50 prime numbers. The prototype of the function is given below.(7.5)


void PrintPrime(void);

Question 7

Write a program to find the number of characters and words in a string inputted by the user. Assume that different words are separated by a single space. (5)

Question 8

Point out the syntactic errors in the following functions


a. (5)

void PrintMe(int n)
{
     cout<<'Hello'<<"\n";
     char ch;
     for(int a = 0, a<10, a = a + 1)
     {
        cin<<ch;
        cout<<'ch'<<ch<<endl;
      }
}


b. (5)

void Rev(char st[])
{
    int len = strlen[st];
    for(int i = 0, i < len/2, i = i +1)
     {
        char temp = st(i);
        st(i) = st(len - 1 - i);
        st(len - 1 - i) = temp;
      }
        st(len) = 0;
        cout<<'done';
}

Question 9

Write the output of the following programs.

a. (5)
#include<iostream.h>
#include<conio.h>
void main()
{
   int j = 1, k = 0;
   while(j <= 6)
   {
     while(k < j)
     {
       cout<<k++<<k++;
     }
       cout<<endl;
       j = j + 2;
   }
}


b. (7.5)
#include<iostream.h>
#include<conio.h>
void add(int&, int);
void eval(int[][4]);
void main()
{
   cout<<'H'<<"\n";
   int Arr[4][4];
   int j = 0;
   while(j < 4)
    {
        int k = 0;
        while(k < 4)
       {
         Arr[j][k] = k;
         k++;
       }
         j++;
    }
  eval(Arr);
}

void eval(int A[4][4])
{
    int j = 0, k;
    while(j<4)
   {
      int res = 0;
      k = 0;
      while(k<4)
       {
       add(res, A[j][k]);
       k ++;
        }
    cout<<res<<endl;
    j ++;
   }
}

void add(int &A, int B)
{
A = A + B;
}

Question 10

Write a function to sort an array of 50 floating point numbers, A[50] by selection sort in increasing order. The prototype is given below. (5)

void Sort(float A[50]);


Question 11

Write a function which returns the number of 'a's and 'A's in a string str. The function prototype is given below. (5)

int NumberOfA(char str[]);



Click here for the Answers