Sunday, November 16, 2008

Question PaperProgramming and Problem solving in C (MC151) : January 2006

Section A : Basic Concepts (30 Marks)
1.“x” and “y” are called
(a) Actual parameters (b) Local variables (c) Formal parameters (d) Local parameters
(e) Global variables.
2.“c” is called
(a) Actual parameter (b) Local variable (c) Formal parameter (d) Local parameter
(e) Global variable.
3.The declaration “void foo (int x, int & y)” is called a
(a) Function body (b) Function type (c) Function stereotype (d) Function prototype (e) Function printtype.
4.The function “foo” returns the following type as result
(a) Integer (b) No result is returned (c) Float (d) Char (e) Double.
5.An example of a value parameter in the code above is
(a) x (b) y (c) c (d) foo (e) fo.
6.C programming language was developed by
(a) Dennis Ritchie (b) Ken Thompson (c) Bill Gate (d) Peter Norton (e) Donald Hearn.
7.When a program is running the value of a constant
(a) Can be changed (b) Cannot be used (c) Is always hidden (d) Cannot be changed
(e) Can be used.
8.The benefit of using enumeration data types in a program is
(a) Program becomes shorter (b) Program becomes longer (c) Program is easy to understand(d) Program executes faster (e) Program become complex.
9.What is the result of the expression 6+12*3–4/2 ?
(a) 22 (b) 25 (c) 40 (d) 52 (e) 45.
10.How many characters can a string hold when declared as char name [20]; ?
(a) 18 (b) 19 (c) 20 (d) 21 (e) 22.
11.What result is in the variable num1 after execution of the following statements?
int j = 1, num1 = 4;
while (++j <= 10)
{
num1++;
}
(a) 11 (b) 12 (c) 13 (d) 14 (e) 15.
12.What is the final value of x if initially x has the value 0?
if (x >= 0)
x += 5;
if (x >= 5)
x += 2;
(a) 0 (b) 2 (c) 5 (d) 7 (e) 8.
13.Which header file contains the function prototypes for the standard input /output library functions and information used by them?
(a) (b) (c) (d) (e) .
14. A function prototype is
(a) A definition of the function
(b) A declaration statement in the called program
(c) A declaration statement in the calling program
(d) A function call in the program
(e) A sterotype in the program.
15.What is the value of i after this segment of the program is executed?
n = 27;
i = 0;
for( i = 0; i <= n; i+= 2 ) {
printf(i );
(a) 25 (b) 28 (c) 27 (d) 26 (e) 29.
16.What is the value of the variable c after the switch statement below?
x = 3;
switch ( x ) {
case 1 : c = 'A'; break;
case 2 : c = 'B'; break;
case 3 : c = 'C'; break;
default: c = 'F'; break;
}
(a) S (b) B (c) C (d) F (e) AB.
17.Which of the following is the function prototype of a function f1 that receives an int pointer and float reference and returns an int pointer?
(a) int f1(int &, float *) (b) float* f1(float &, int &) (c) int* f1 (int *, float &)
(d) int f1 *(int *, float &) (e) int f1(&int,*float).
18.Consider the following declaration :float a, b;
How much memory will be reserved for the above two declared variables.
(a) 1 bytes (b) 4 bytes (c) 8 bytes (d) 16 bytes (e) 20 bytes.
19.What is the return value of the following function if the function is called as
int value = fun(6);
int fun(int n)
{
if( n = = 1 n = = 2) return 1;
else return( fun(n-1) + fun(n-2) );
}
(a) 1 (b) 2 (c) Syntax error (d) 8 (e) 5.
20.The getchar() function reads a
(a) String from a file (b) Character from a file (c) String from the keyboard
(d) Character from the keyboard (e) Word from the file.
21.FILE is -------------
(a) Stack (b) Pointer (c) Union (d) Structur (e) Variable.
22.Multiline macros can be defined by placing ____ at the end of each line except the Last.
(a) / (b) # (c) @ (d) \ (e) $.
23.Which of the following is an advantage of using macros over functions?
(a) Functions must have parameters; macros do not
(b) The code associated with a function is expanded in line
(c) Values passed to functions must be of a specific data type; values passed to macros do not
(d) When macros are used many times in a program they are expanded each time
(e) The code associated with a function is not expanded in line.
24.m = 5 and y = ++m. The value of m and y after incrementation is
(a) m is 5 and y is 5 (b) m is 5 and y is 6 (c) m is 6 and y is 6
(d) m is 6 and y is 5 (e) m is 7 and y is 5.
25.The storage class of a local variable is
(a) Auto (b) Static (c) Extern (d) Register (e) Default.
26.In mixed mode expressions,
(a) Operands of lower type get automatically converted to higher type
(b) Operands of higher type get automatically converted to lower type
(c) Operands of higher and lower type get interchanged
(d) Operands of lower and higher type remain unchanged
(e) Operands of lower type get automatically converted to lower type.
27.If you declare an array without stating the elements it will be set to
(a) A null value (b) Zero (c) Garbage value (d) Set of characters (e) Set of words.
28.Write the last element of the following array.
Char flag[]=“FALSE”
(a) E (b) e (c) \0 (d) “ ” (e) /0.
29.Which of the following functions are used in unformatted data files?
(a) fscanf (b) fwrite (c) fread (d) fwrite & fread (e) fscanf & fwrite
30.Which of the following is “stringzizing operator”?
(a) $ (b) % (c) # (d) ? (e) &&.
Section B : Problems (50 Marks)
1.
a. Write a program to display the sum and count of all numbers between 100 and 200 which are divisible by 7.
b. Write a program in C language to print Armstrong numbers between 1 to 500.
(5 + 5 = 10 marks)
2. Write a Program in C language to perform bubble sort. (10 marks)
3.
a. Write a Program to convert a decimal into its binary representation using recursion.
b. Write a program in C to demonstrate static variables using functions. (5 + 5 = 10 marks)
4. Write a program in C language to swap values of the variables using call by value and call by reference. (10 marks)
5.
a. What's the difference between these two declarations?
struct x1 { ... };
typedef struct { ... } x2;
b. I am trying to declare a pointer and allocate some space for it, but it's not working. What's wrong with this code?
char *p;
*p = malloc(10); (6 + 4 = 10 marks)
Section C : Applied Theory (20 Marks)
6.
a. Write a C Program to read student records from a binary file and to display them on screen.
b. Write a C program to sort ‘n’ books based on book-id using structures?
(The elements of structure are book-id, title, author and price)
c. Explain briefly on nested structures? (10 + 5 + 5 = 20 marks)
Suggested Answers
1.
Answer : (c)
Reason: The x and y are called as formal parameters according to the definition of function.
2.
Answer : (b)
Reason: C variable is local to the function that is why it is called to local variable.
3.
Answer : (d)
Reason: Function prototype is the declaration of the structure of function.
4.
Answer : (b)
Reason: No return type is mentioned
5.
Answer : (a)
Reason: The other parameter is address parameter.
6.
Answer : (a)
Reason: Dennis Ritchie developed C language.
7.
Answer : (d)
Reason: The definition of constant says that it cant be changed.
8.
Answer : (c)
Reason: Enumeration types minimize complexity.
9.
Answer : (c)
Reason: First * is evaluated and next / is evaluated and then + or + evaluated.so 40 is the right choice.
10.
Answer : (b)
Reason: String occupies one character as null.
11.
Answer : (d)
Reason: 14 is the right choice after the execution of program.
12.
Answer : (d)
Reason: First x becomes 5 and then x gets added to 2 and result is 7.
13.
Answer : (b)
Reason:
Header file contains the function prototypes for the standard input /output library functions and information used by them.
14.
Answer : (c)
Reason: Function prototype is the declaration statement in the calling program.
15.
Answer : (b)
Reason: The value of i wll be 28 after execution of the code.
16.
Answer : (c)
Reason: 3 matches the case :3 and C will be printed.
17.
Answer : (c)
Reason: C is the right choice according to the statement .
18.
Answer : (c)
Reason: Float occupies 4 bytes so total 8 bytes .
19.
Answer : (d)
Reason: D is the right choice based on the recursive call.
20.
Answer : (d)
Reason: Reasongetchr()function reads the character from the key board.
21.
Answer : (d)
Reason: File is a structure.
22.
Answer : (d)
Reason: Multiline macros can be defined using \.
23.
Answer : (b)
Reason: The code associated with a function is expanded in line.
24.
Answer : (d)
Reason: First m is incremented and then y is initialized.
25.
Answer : (a)
Reason: For variable the default storage class is auto.
26.
Answer : (a)
Reason: In mixedmode expressions Operands of lower type get automatically converted to higher type.
27.
Answer : (c)
Reason: Garbage value will be set if an array is not initialized.
28.
Answer : (c)
Reason: The last element in the string is null character.
29.
Answer : (d)
Reason: Unformatted data files uses fread and fwrite.
30.
Answer : (c)
Reason: “stringzizing operator is # .

6 comments:

Anonymous said...

I needed some info and was searching on Yahoo.co.uk for it. I visited each of the first 10 pages that came up but didn’t get any relevant result... I then luckily found your diamond message board in the dirt and thought to check it out. This is what I wanted!

Cheers people at icfaimcapapers.blogspot.com and keep your brilliant effort up.

[color=#fffafa][URL=http://www.iron-science.co.uk/]Sports Nutrition[/URL] [URL=http://www.iron-science.co.uk/]Sports Supplements[/URL] [URL=http://www.iron-science.co.uk/]bodybuilding[/URL] [URL=http://www.iron-science.co.uk/]bodybuilding supplements[/URL] [/color]

Anonymous said...

I've always liked things like sand clocks, lava lamps, and the like to type of just dish out space staring at it as a cut of catharsis. In a opportunity, it helps me with meditation, to free stress and decent fantasize fro nothing. That's why since I was a kid, a substitute alternatively of dolls and cars I've always at ease more of such pieces like sand clocks, lava lamps, tuneful boxes etc. So I was most charmed when I base the[url=http://www.dealtoworld.com/goods-1260-2-Laser++LED+Light+Show+Laser+Top+Gyroscope+with+Music+Effects.html] 2-Laser + LED Inconsiderable Appear Laser Top Gyroscope with Music Effects[/url] from DealtoWorld.com under the Toys section. It's like a harmonious box, a spinning better, and a radiance verify all rolled into one. Which is great amusement! The gyroscope wishes whirl after round a minute. The laser slight pretension with accompanying music makes this gyroscope a measure corresponding exactly toy that my friends get also been most amused with.

My dogs are also fair curious nearly the laser gyroscope I got from DealtoWorld.com. They evermore cleave to the gyroscope as it spins, although at first they kept barking at the laser insight accompany, and also because it produces music. But after they got worn it, they've stopped barking but simply save up following the gyroscope whenever I start spinning it. Kids are also bonny amused by it. Off it's meet to take pleasing toys about the blood so that you can pull out the bit of frippery trifle with on while the kids are being amused or playing with it while you open to prepare scoff or receive changed. The gyroscope is inseparable such trinket with this purpose.

The gyroscope I bought from DealtoWorld.com has a dragon as a design on it, and produces a light exposition with red, dispirited, and common colours. Nick a look at the pictures I've uploaded of the gyroscope with laser light show. The music produced from the gyroscope is not that expert but good adequacy to entertain any supplementary guest to the house. The gyroscope is red and raven, making it look exceedingly coolth, and measure virile with that dragon imprint.

The music luminescence make clear gyroscope runs on 6 LR44 batteries, which are replaceable anyway. I've also acclimatized this gyroscope to their heels my girlfriend during our anniversary celebration. I did the cheesy matter of decorating the hotel cell with roses and when I led her in, I started up the gyroscope as well so that the laser brighten clarify produces a fresh effect. I also had some battery operated candles so all the light effects created a sort of romanticist atmosphere. She loved it, past the style, to my relief. I also bought the candles from DealtoWorld.com. These days it seems to be my non-fulfilment shopping put suitable all gifts and ideas in behalf of romanticist occasions.

Since Christmas is coming, this laser radiance upstage gyroscope can perhaps be a talented Christmas contribution in behalf of the toddler or in spite of the favoured! Alternatively, the gyroscope can simply be a gracious addition to the ordinary Christmas decorations. I can take it as given placing it near the Christmas tree and perhaps spinning it when guests hit town in the house. Looks like [url=http://www.dealtoworld.com]DealtoWorld.com[/url] is getting my function still again!

Anonymous said...

Peyton Manning Jersey axiotakix
J.J. Watt Youth Jersey axiotakix
Cheap Andrew Luck Jersey axiotakix
http://www.nikecardinalsnflstore.com

Anonymous said...

Once we think about the term your message really like, not just in regards to an intimate relationship using another, nonetheless like a feeling that is engendered should you have miltchmonkey an improved connection on your own much too : or even as the a sense more significant unity with the family or human race ( blank ) it develops into even more superior that most anybody is looking to get in your life is really like.

Anonymous said...

AFter all, the iFea behinF promoting is [url=http://www.germanylovelv.com/]Louis Vuitton Outlet[/url]
increase revenue. On the surFace that makes sense. However, For those who look a little closer, what you coulF possibly FinF are expenses which might be out oF whack or not getting invoices out in a timely manner. A very well printeF name. That is right, it can be as simple like a very well printeF name, but it seriously counts For a lot. Many business carFs get noticeF First since oF a properly printeF name.
But irregarFless oF just what the Fealership Foes in promotion, extravagant balloons, unique Features, etcetera., all those cars will not sell themselve[url=http://www.germanylovelv.com/]Louis Vuitton Outlet/[/url]
You go For a check push using your buyers anF solution their queries For what appears like an eternity. You alreaFy know they're engageF, but just are unable to make up their thoughts.
Lets Face it, talking about the beneFits can get you anywhere with your target client[url=http://www.germanylovelv.com/]louis vuitton knolckoffs[/url]
People in general are only interesteF in what woulF be the aFvantages [url=http://www.germanylovelv.com/]louis vuitton knolckoffs[/url]
them iF they take up your oFFer. What consumers value most are the beneFits they can get From your organization whats in it For them? IF you can clearly proviFe them with the beneFits, then your message is valuable anF signiFicant..

Anonymous said...

JcI b olID http://senmonerumesu.com/ tkWJ a vqYK hnB [url=http://senmonerumesu.com/]エルメス エブリン[/url] HdS m tsIE http://hannbaikochi1jp.com/ okKO y tfGU tdO [url=http://hannbaikochi1jp.com/]コーチ 財布[/url] ImE geJF m agKN http://dendoukochiinjp.com/ xgYU v tgKP inJ [url=http://dendoukochiinjp.com/]コーチ バッグ 新作[/url] MsX tnBY h ojBI http://sinsakukochi1jp.com/ nwGX p dfZM kaY [url=http://sinsakukochi1jp.com/]コーチ バッグ 新作[/url] QmY wiDB m xuNS http://hannbaierumesu.com/ uiZO w yvJE slS [url=http://hannbaierumesu.com/]エルメス[/url] FsE x jlQZ http://nihonkochiinjp.com/ cgZD k ejNO cgS [url=http://nihonkochiinjp.com/]コーチ アウトレット オンライン[/url] JjH f chZO http://louisnevuittonedspeedy.webs.com/ hpYM m dwVL gdG [url=http://louisnevuittonedspeedy.webs.com/]louis vuitton shoes[/url] EwU o mvOR http://kochijapkangeia.com/ teVF o ebWK xxJ [url=http://kochijapkangeia.com/]コーチ バッグ 斜めがけ[/url] CgR gcGV v apSN http://saiyasuneerumesu.com/ jjXN t jlWZ hbR [url=http://saiyasuneerumesu.com/]エルメス バッグ[/url]