Computer Programming Test paper

Question 2: Write a function Product(....) that receives two integer numbers as an argument to the function and return product of two numbers without using multiplication (*) operator. (Don't use built-in functions). 

Hint: Use Addition

Question 3: Write a Function Fill2DArray(...) that takes 2D aray, no of rows, no of columns and a number as arguments to the function and then auto-fill the matrix like table. Then print the array in main. For example the 2 sample program outputs are: 

e.g. Enter a number: 3                                                   e.g. Enter a number: 5

| 3      6      9      12  |                                                          | 5        10       |
| 15   18     21    24  |                                                          | 15      20       |
| 27   30     33    36  |                                                          | 25      30       |
| 39   42     45     48 |                                                          | 35      40       |      

Question 4: Write a function merge_string(...) that takes three 1-D character arrays A, B and C as an argument to the function. Your function should merge string A and string B in to the third string C.

                                            e.g. String 1 (A) is: "This is"
                                                   String 2 (B) is: "a String"
                                                   String 3 (C) is: "This is a String"

OR

struct STUDENT{
            int rollno, age;
            char name[80];
            float marks;
            int month, date, year;
            // write getter setter here ;
};

In main declare an array of 10 students and input the student details using setter functions. Print the details of 10 students using getter function. 

Question 5: An integer is said to be prime if it is divisible by only 1 and itself. For example 2, 3, 5 and 7 are primes but 4,6,8 and 9 are not. Write a function isPrime(...) that take an integer number as an argument to the function and determines whether a number is prime or not. 

OR

Declare two pointers of suitable type and point them to two variables. Then sum two numbers using pointers. Store and print the result using third pointer by pointing to answer variable. 

Question 6: Define the following. Must provide coded example: 

        a. What is an inline function ?
        b. Difference between pass by value and pass by reference parameters.
        c. What is default parameter?
        d. What is function overloading?

No comments:

Post a Comment