0% found this document useful (0 votes)
176 views6 pages

C Questions

The document contains 32 multiple choice questions about C programming concepts such as operators, data types, pointers, arrays, functions, loops, conditional statements, strings, structures, preprocessor directives, and input/output. The correct answers are provided for each question.

Uploaded by

Ranjith Ranjith
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views6 pages

C Questions

The document contains 32 multiple choice questions about C programming concepts such as operators, data types, pointers, arrays, functions, loops, conditional statements, strings, structures, preprocessor directives, and input/output. The correct answers are provided for each question.

Uploaded by

Ranjith Ranjith
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

The operator + in a+=4 means


a)a=a+4 <ANS>
b)a+4=a
c)a=4
2. Which of the following is the correct way of declaring a float pointer:
a) float ptr
b) float *ptr <ANS>
c) *float ptr;
d) None of the above
3. Time taken for addition of element in queue is
a) O(1)
b) O(n)
c) O(log n) <ANS>
d) None of these options

4. Pointers are of
a) integer data type
b) character data type
c) unsigned integer data types
d) None of these <ANS>
5. Which of following is a keyword used for a storage class:
a) printf
b) external
c) auto <ANS>
d) scanf
6. When a 'C' function call is made, the order in which parameters are passed to
the function are pushed into the stack is
a) left to right
b) right to left <ANS>
c) bigger variables are moved first than the smaller variables
d) smaller variables are moved first than the bigger ones
e) none of the above

7. Memory allocation of variables declared in a program is


a) allocated in RAM
b) allocated in ROM
c) allocated in stack <ANS>
d) assigned to registers

8. Find the output of the following program :


int *p, *q;
p=(int *)1000;
q=(int *)2000;
printf("%d",(q-p));
a) 100
b) 200
c) 500 <ANS>
d) 1000

9. What is the output of the following code?


#include<stdio.h>
void main()
{
int s=0;
while(s++<10)
{
if(s<4 && s<9)
continue;
printf("\n%d\t",s);
}
}

a) 1 2 3 4 5 6 7 8 9
b) 1 2 3 10
c) 4 5 6 7 8 9 10 <ANS>
d) 4 5 6 7 8 9

10.Array passed as an argument to a function is interpreted as


a) Address of the array
b) Values of the first elements of the array
c) Address of the first element of the array <ANS>
d) Number of element of the array

11. The size of a structure can be determined by


a. size of variable name
b. size of (struct tag)

a) Only a
b) Only b
c) Both a and b <ANS>
d) None of these options
12. #define MAX_NUM 15
Referring to the sample above, what is MAX_NUM?
a) MAX_NUM is an integer variable.
b) MAX_NUM is a linker constant.
c) MAX_NUM is a precompiler constant.
d) MAX_NUM is a preprocessor macro. <ANS>
e) MAX_NUM is an integer constant.
13. int x = 2 * 3 + 4 * 5;
What value will x contain in the sample code above?
a) 22
b) 26 <ANS>
c) 46
d) 50
e) 70
14. C is which kind of language?
a) Machine
b) Procedural <ANS>
c) Assembly
d) Object-Oriented
15.
int x = 0;
for (x=1; x<4; x++);
printf("x=%d\n", x);
What will be printed when the sample code above is executed?
a) x=0
b) x=1
c) x=4 <ANS>
d) x=5
16.
int x = 3;
if( x == 2 );
x = 0;
if( x == 3 )
x++;
else x += 2;
What value will x contain when the sample code above is executed?
a) 1
b) 2 <ANS>
c) 3
d) 4
e) 5

17.
char *ptr;
char myString[] = "abcdefg";
ptr = myString;
ptr += 5;
What string does ptr point to in the sample code above?
a) fg <ANS>
b) efg
c) defg
d) None of the above
18.
double x = -3.5, y = 3.5;
printf( "%.0f : %.0f\n", ceil( x ), ceil( y ) );
printf( "%.0f : %.0f\n", floor( x ), floor( y ) );
What will the code above print when executed?
a) -3 : 4
-4 : 3 <ANS>
b) -4 : 4
-3 : 3
c) -4 : 3
-4 : 3
d) -4 : 3
-3 : 4
e) -3 : 3
-4 : 4
19.
x = 3, counter = 0;
while ((x-1))
{
++counter;
x--;
}

a) 0
b) 2 <ANS>
c) 3
d) 4
20. Which one of the following will read a character from the keyboard and will
store it in the variable c?
a) c = getc();
b) getc( &c );
c) c = getchar( stdin );
d) getchar( &c )
e) c = getchar(); <ANS>
21. Which one of the following C operators is right associative?
a) = <ANS>
b) ,
c) []
d) ^
e) ->
22. What does the "auto" specifier do?
a) It automatically initializes a variable to 0;.
b) It indicates that a variable's memory will automatically be preserved. <ANS>
c) It automatically increments the variable when used.
d) It automatically initializes a variable to NULL.
e) It indicates that a variable's memory space is allocated upon entry into the
block.
23. How do you include a system header file called sysheader.h in a C source fil
e?
a) #include <sysheader.h> <ANS>
b) #incl "sysheader.h"
c) #includefile <sysheader>
d) #include sysheader.h
e) #incl <sysheader.h>

24. Which one of the following printf() format specifiers indicates to print a d
ouble value in decimal notation, left aligned in a 30-character field, to four (
4) digits of precision?
a) %-30.4e
b) %4.30e
c) %-4.30f
d) %-30.4f <ANS>
e) %#30.4f
25. int y[4] = {6, 7, 8, 9};
int *ptr = y + 2;
printf("%d\n", ptr[ 1 ] );
What is printed when the sample code above is executed?
a) 6
b) 7
c) 8
d) 9 <ANS>
e) The code will not compile.
26. int i = 4;
int x = 6;
double z;
z = x / i;
printf("z=%.2f\n", z);
a) z=0.00
b) z=1.00 <ANS>
c) z=1.50
d) z=2.00
e) z=NULL

27. Which one of the following variable names is NOT valid?


a) go_cart
b) go4it
c) 4season <ANS>
d) run4
e) _what
28. Which one of the following is NOT a valid identifier?
a) __ident
b) auto <ANS>
c) bigNumber
d) g42277
e) peaceful_in_space
29. Which one of the following is NOT a valid C identifier?
a) ___S
b) 1___ <ANS>
c) ___1
d) ___
e) S___
30. char * dwarves [] = {
"Sleepy",
"Dopey" "Doc",
"Happy",
"Grumpy" "Sneezy",
"Bashful",
};
a) 4
b) 5
c) 6
d) 7
e) 8

31.
#include <stdio.h>
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( "%d -- %d\n", x, y );
}
int main()
{
func();
func();
return 0;
}
a)
1 -- 1
1 -- 1
b)
1 -- 1
2 -- 1
c)
1 -- 0
1 -- 0
d)
1 -- 1
1 -- 2 <ANS>
32.
c = getchar();
What is the proper declaration for the variable c in the code above?
a) char *c;
b) unsigned int c;
c) int c;
d) unsigned char c;
e) char c; <ANS>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy