Declarations – 2.Image.Marked .pdf

File information


Original filename: Declarations – 2.Image.Marked.pdf

This PDF 1.4 document has been generated by Online2PDF.com / Online2PDF.com; modified using iTextSharp 5.0.5 (c) 1T3XT BVBA, and has been sent on pdf-archive.com on 23/05/2014 at 13:35, from IP address 124.123.x.x. The current document download page has been viewed 377 times.
File size: 138 KB (4 pages).
Privacy: public file


Download original PDF file


Declarations – 2.Image.Marked.pdf (PDF, 138 KB)


Share on social networks



Link to this file download page



Document preview


C Programming Questions and Answers – Declarations – 2
“a fou d s 1000+ Interview Questions & Answers on C helps anyone preparing for TCS and other
companies C interviews. One should practice these 1000+ interview questions and answers continuously
for 2-3 months to clear TCS interviews on C Programming language.

Here is a listi g of C uestio s a d puzzles o
solutions:

De la atio s alo g ith a s e s, e pla atio s a d/o

1. Which of the following declaration is illegal?
a) ha *st = Best C p og a

i g lasses

“a fou d

;

) ha st [] = Best C p og a

i g lasses

“a fou d

;

) ha st [

] = Best C p og a

d) ha [] st = Best C p og a

i g lasses
i g lasses

“a fou d
“a fou d

;
;

View Answer
Answer:d
Explanation:char[] str is a declaration in Java, not in C.

2. Which keyword is used to prevent any changes in the variable within a C program?
a) immutable
b) mutable
c) const
d) volatile
View Answer
Answer:c
Explanation:const is a keyword constant in C program.

3. Which of the following is not a pointer declaration?

a) char a[10];
b) char a[] = { ′, ′, ′, ′};
c) char *str;
d) char a;
View Answer
Answer:d
Explanation:Array declarations are pointer declarations.

4. What is the output of this C code?

#include <stdio.h>

void main()

{

int k = 4;

float k = 4;

printf("%d", k)

}

a) Compile time error
b) 4

c) 4.0000000
d) 4.4
View Answer
Answer:a
Explanation:Since the variable k is defined both as integer and as float, it results in an error.
Output:
$ cc pgm8.c
pg

. : I fu tio

ai :

pg

. : : e o : o fli ti g t pes fo k

pg

. : : ote: p e ious defi itio of k

pg

. : : a i g: fo

pg

. : : e o : e pe ted ;

as he e

at %d e pe ts t pe i t , ut a gu e t has t pe dou le
efo e } toke

5. Which is false ?
a) A variable defined once can be defined again with different scope
b) A single variable cannot be defined with two different types in the same scope
c) A variable must be declared and defined at the same time
d) A variable refers to a location in memory
View Answer
Answer:c
Explanation:It is not an error if the variable is declared and not defined. For example – extern
declarations.

6. A variable declared in a function can be used in main
a) True
b) False

c) True if it is declared static
d) None of the mentioned
View Answer
Answer:b
Explanation:Since the scope of the variable declared within a function is restricted only within that
function,
the above statement is false.

7. The name of the variable used in one function cannot be used in another function
a) True
b) False
c) May be
d) None of the mentioned
View Answer
Answer:b
Explanation:Since the scope of the variable declared within a function is restricted only within that
function, the same name can be used to declare another variable in another function.


Document preview Declarations – 2.Image.Marked.pdf - page 1/4

Document preview Declarations – 2.Image.Marked.pdf - page 2/4
Document preview Declarations – 2.Image.Marked.pdf - page 3/4
Document preview Declarations – 2.Image.Marked.pdf - page 4/4

Related documents


declarations 2 image marked
variable names 2 image marked
variable names 1 image marked
constants 1
java test
constants 2

Link to this page


Permanent link

Use the permanent link to the download page to share your document on Facebook, Twitter, LinkedIn, or directly with a contact by e-Mail, Messenger, Whatsapp, Line..

Short link

Use the short link to share your document on Twitter or by text message (SMS)

HTML Code

Copy the following HTML code to share your document on a Website or Blog

QR Code

QR Code link to PDF file Declarations – 2.Image.Marked.pdf