S.B. Roll
No……
Computer Programming
and Applications
3rd
Exam/ECE/6160/May’09
Duration 3
Hrs.
1.
Choose the correct or best alternative in the
following:
a.
Literal means
i.
A string.
ii.
A string constant.
iii.
A character
iv.
An alphabet.
b.
Choose the correct answer
i.
Casting refers to implicit type conversion
ii.
Coercion refers to implicit type conversion.
iii.
Casting means coercion.
iv.
Coercion refers to explicit type conversion.
c.
Printf(“%d”, printf (“tm”));
i.
Results in a syntax error
ii.
Outputs time
iii.
Outputs garbage
iv.
Outputs tim and terminates abruptly
d.
Output of the following program fragment is
X=5
Y= x++
Printf (“%d%d”; x, y)
i.
5,6
ii.
5,5
iii.
6,5
iv.
6,6
e.
The value of an automatic variable that is
declared but not initialized will be
i.
0
ii.
-1
iii.
Unpredictable
iv.
None of these
f.
Consider the following program main()
{
float a=0.5, b=0.7;
If
(b < 0.8)
If
(a<0.5) printf(“ABCD”);
Else
printf(“PQR”);
Else
printf(“JKLF”);
}
The
output is
i.
ABCD
ii.
PQR
iii.
JKLF
iv.
None of these
g.
The following program fragment
Int
*a;
*a=7;
i.
Assigns 7 to a
ii.
Results in compilation error
iii.
Assigns address of a as 7
iv.
Segmentation fault
h.
A pointer variable can be
i.
Passed to a function.
ii.
Changed within function
iii.
Returned by a function.
iv.
Assigned an integer value
i.
The 4-bit binary number 0111 represents
i.
15
ii.
-7
iii.
7
iv.
-1
j.
A byte corresponds to
i.
4 bits
ii.
8bits
iii.
16 bits
iv.
32 bits
Section
–B
Note : Attempt any five parts. Each
question carries 6 marks
2. Write a C program that reads a fixed point real
number in a character array and then displays right most digit of the integral
part of number.
3.
Output the number x =56.1624 under the following
format specification
a.
Printf(“%7.2f”,x)
b.
Printf(“%f”,x)
c.
Printf(“%8.2f”,x)
d.
Printf(“%e”,x)
4.
Write a C program that uses ‘for’ construct to
find the sum of the following harmonic series for a given value of n and
display the sum.
1+1/2+1/3+……+1/n
5.
Write a C program fragment using do…. While”
construct to print out even numbers between 10 to 100 making sure that two
number are written per line.
6.
Given an integer, write a C program that
displays the number as follows
First line : all
digits of integer
Second line : all except first right most digit
Third line : all except two light most digits
List line : left most digit
7.
Describe the output of the following C program
fragment
Main ()
{ int k =0, x=0;
While (k<25)
{ if (k%5==0)
{ x+=k;
Print f(“%d *,”x)
}
++k;
{
Printf(“/n jd “x+k,);
}
Section –C
Note : Attempt any three questions
8.
a.
Write a C program to compute the balue of sin
function. The loop must terminate when the absolute
Value
of the term is less than 0.00001
Sin
x=x-x3/3!+x5!-x7/7!+….
b.
Write a switch statement that will examine the
value of an integer variable flag and print the following messages;
It
is hot weather; if flag has value 1
It
is a stormy weather, if flag has value 2
It
is sticky weather; if flag has value 3
It
is a pleasant weather, otherwise
9.
a.
Define a structure name student containing two
fields ‘name’ and ‘marks’
b.
Declare an array of structure having 50 elements
of student type.
c.
Write an input statement for inputting the marks
and the names of 50 students defined as above.
d.
Write a complete C program to compute and print
the names of those students who have got more than 80 marks. Also print their
marks along with their names.
10.
a.
Write a recursive function in C to compute the
value of x where n is a positive integer and x has a real value.
b.
Write a function ‘exchange’ to interchange the
values of two variables say x and y. illustrate the use of this function in
calling program. Assume that x and y are defined as global variables.
11.
a.
Write a C function that returns 1 if the
arguments is a prime number is a prime number and returns 0 otherwise.
b.
Write a C
function for searching an elements in an array of size N. Assume that elements
in array are stored in ascending order.
0 comments:
Post a Comment
North India Campus