# Computer Programming and Utilization July 2011

GUJARAT TECHNOLOGICAL UNIVERSITY

B.E Sem-I/II Examination June-July 2011

Subject code: 110003 Subj.Name: Computer Programming & Utilization

Date: 23/6/2011                                Total Marks: 70

Time: 10:30 am to 1:00pm

Instructions:

1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.

Q.1 (a) Draw a flowchart to count odd numbers and making their total from given 08 N numbers.

(b) Give the output of the following code. Give the explanation for the output. 06

1. int x = 10; void main()

{

int x = 15,y; y = x++;

printf(“%d %d”,++y, x++);

}

1. void main()

{

int x[] = {1,2,3,4,5}; printf(“%d”,fun(&x[2]));

}

int fun(int *a)

{

int i=0,sum=0; for(i=0;i<2;i++,a++) sum += *a; return(sum);

}

1. int i; for(i=5;i<15;i++) {

printf(“%d\n”,i); i = i – 1;

}

Q.2 (a) Answer the following questions.                                                                                                                          07

 1. Define an array of 10 integer pointers. 2. Define an array of structure with integer, string and float as members. Size of array is 10. 3. Give a prototype of function accepting an integer pointer and a float as arguments and returns nothing. 4. How can you define infinite loop using while? 5. Give the meaning of int (*f)(int,int) and int *f(int,int); 6. Justify, “C is middle level language. 7. How can you allocate memory dynamically for 10 floating point

 numbers?

(b)  What is looping? Explain different types of loops in C and compare them.                                                  07

Show how to sum 1 to 10 using each of these loops.

OR

(b) What is structure? How can we access structure members? Clear use of 07 nested structure using example. Compare structure with union.

Q.3  Write a C program to print multiple of N from given range of unsigned 07 integers. For example, if N=5 and range is [17, 45] it prints

20,25,30,35,40,45.

(b)  Compare following.                           07

1. Software and hardware
2. Object and Procedure oriented programming

OR

Q.3 Write a C program to accept a string and print every third character from 07 string only if it is lower case.

Explain the multiple if (ladder if) with example. Give the example using it. 07

Q.4   Write a C function to exchange two numbers and use it to reverse an array 07 of 10 integers accepted from user.

(b)  Explain following with example w. r. to C++. 07

1. new operator
2. parameterized constructor

OR

Q.4  Write a C function to reverse a word. Use it to reverse each word of a string 07 given by user.

Explain following with example w. r. to C++.      07

1. Copy constructor
2. Static data member and static function member

Explain the concept of call by reference and return by reference with proper 07 example.

Define a class to represent employee with id, name and salary with 07 necessary constructors. Class should support method maxSAL() to give larger salary from two objects. Write a C++ program which accepts details of 10 employees and print employee whose salary is highest using maxSAL() method.

OR

What are default arguments? Demonstrate its use with proper example.                           07

Define a point class with x and y coordinates with necessary constructors.                                 07

Provide a friend function to add two point objects. Write main() to demonstrate its use.

*************