Sona Programming Club

Sona Programming Club

Share

09/08/2012

Live demonstration of Aspirations2020 contest will be done on 10/08/2012 at lecture hall 502.

11/04/2012

Date of post: 5.4.12
Category: Questions
Number: 10
Post content:
Sona Programming Club ( SProC )
"Let us C beyond the C"

Answers for last weeks questions:
1.Answer: All three [ In-fact the option should have been All the above ]

2. Answer: interrupt

3. Answer: char

4. Answer: Equal
Explanation: The comparison is made bitwise. ( So, both will be equal ).

5. Answer: Function

Questions to be answered on or before 11.4.12:
1. Predict the output [2 marks]
main() { char str[] = "Sona\0Programming\0Club" ; printf ( "%s %s %s\n", str + 17, str + 5, str ) ; }

Sona Programming Club
Club Programming Sona
Syntax error
Garbage values

2. What is the output? [2 marks]
main() { int i = 0 ; ! i && printf ( "Text" ) ; }

Text
No output
Syntax error
None of the above

3. What would be the output? [2 marks]
main () { printf ( "What\0are you doing ? " ) ; }

What are you doing ?
What
No output
Error

4. Predict the output [1 mark]
main() { printf ( "Information" ) || printf ( "Technology" ) ; }

Information
Technology
TechnologyInformation
InformationTechnology

5. Find the output [1 mark]
main() { printf ( "%d", printf ( "2+" ) + printf ( "2=" ) ) ; }

2+2=4
42+2=
2=2+4
Error

Website: www.sonasproc.tk

04/04/2012

Date of post: 30.3.12
Category: Questions
Number: 9
Post content:
Sona Programming Club ( SProC )
"Let us C beyond the C"

Answers for last week:
1. Answer: If you have used gcc compiler, the answer would be 4 5 5. If Turbo C complier, is used, the answer will be 2 5 5.
Explanation: The sizeof some data types will vary from compiler to compiler. Each character takes 1 byte in both the compilers. So, the size if 5 including the NULL.
( Both are evaluated as right answers ).
-------------------------------------------------------------------------------------
2. Answer: 1==1 is TRUE.
Explanation: The conditional operator is used.
-------------------------------------------------------------------------------------3. Answer: 6
Explanation: The '\n' is taken as a single character and NULL is not counted
-------------------------------------------------------------------------------------4. Answer: No output
Explanation: Both strings are equal and hence 0 is returned by strcmp. 0 is false condition and hence the statement printf is not executed.
-------------------------------------------------------------------------------------5. Answer: 5 4
Explanation: sizeof returns ( number of bytes occupied ) value including NULL and strlen returns ( number of characters ) value excluding NULL.
-------------------------------------------------------------------------------------
Questions to be answered on or before 4.4.12:
1. Which of the following declaration(s) is(are) correct ? [2 marks] (i) enum cricket {Gambhir,Smith,Sehwag}c;
(ii) enum cricket {Gambhir,Smith,Sehwag};
(iii) enum {Gambhir,Smith=-5,Sehwag}c;
(iv) enum c {Gambhir,Smith,Sehwag};

(i)
(i) (ii)
(i) (iii)
(i) (ii) (iii)
All three


2. Which of the following does not modify data type in C? [2 marks]

extern
interrupt
huge
register
All the above


3. Which of the following is integral data type in C? [2 marks]

float
void
char
none


4. Predict the output [1 mark]
main(){ int a=-5; unsigned int b=-5u; if(a==b) printf("Equal"); else printf("Empty"); }

Equal
Empty
Error


5. Which of the following is not derived data type? [1 mark]

Function
Pointer
Enumeration

Website: www.sonasproc.tk
Happy programming !

Sona Programming Club This site is to improve the programming skills of the students of Sona College of Technology.

16/02/2012

Date of post: 15.02.2012
Category: Question
Question number: 2
Post content:
Sona College of Technology
Programming Club ( SProC )
“Let us C beyond the C”
Answers for questions asked on 14.02.2012:
1. a) 23
2. main() { int a = 10 ; printf ( “%d”, a ) ; }
3. c) do.. while
4. Not equal ( since variable a is declared as int and 2.5 is assigned, implicit type conversion takes place and hence 2 is stored in a )
5. True ( due to implicit type conversions )

Questions for 15.02.2012 ( based on array ):

1. Predict the output: ( 1 )
main() { int a[]={1, 5, 12} ; printf("%d %d",a[0+1],a[1]+1 ); }
a) 2 6 b) 5 6 c) 5 12 d) error
----------------------------------------------------------------------------------------------------------

2. Debug the code: ( Write the correct code – Output should be 5,3,2 ) ( 1 )
main() { float a[2] = { 5, 3, 2 } ; printf ( “%d,%d”,a[0],a[1],a[2] ) ; }
---------------------------------------------------------------------------------------------------------

3. Debug the code: ( Output : SPC ) ( 2 )
main() { char s[] = “SProC” ; printf ( “%c%c%c”, 0[s], s[1], s[strlen(s)] ) ; }
----------------------------------------------------------------------------------------------------------

4. Predict the output: ( 1 )
main() { int a[5] ; printf ( “%d”, a[3] ) ; }
----------------------------------------------------------------------------------------------------------

5. Predict the output: ( 2 )
main() { char a[8] = “Welcome” ; printf ( “%c,H”, a[8] ) ; }
a) Garbage,H b) ,H c) Error d) e,H
----------------------------------------------------------------------------------------------------------

Topmost Coders :
1. D. Jeevaraj – ECE
2. A. Hariharan – ECE
3. M. Anbarasu – ECE
4. P. Vasanth Kumar – Civil
5. M. Tamil Selvam – Civil
6. R. Sthanu Subramanian – Civil

Note:
(1). All the above students hold the first rank.
(2). Contact [email protected] for any queries and for feedback

Happy programming !

Want your school to be the top-listed School/college in Salem?
Click here to claim your Sponsored Listing.

Website

Address


Salem
636005