C Programming

C Basics — Practice MCQs for CCAT

40 Questions Section B: Programming C Programming

Practice 40 C Basics multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.

Q1.
Who is the creator of C programming language?
ADennis Ritchie
BBjarne Stroustrup
CJames Gosling
DKen Thompson
Show Answer & Explanation

Correct Answer: A — Dennis Ritchie

C was developed by Dennis Ritchie at Bell Labs in the early 1970s.

Q2.
C language was originally developed for which operating system?
AUNIX
BWindows
CLinux
DDOS
Show Answer & Explanation

Correct Answer: A — UNIX

C was developed to write the UNIX operating system.

Q3.
Which of the following is a valid C standard?
AC89
BC++11
CJava 8
DPython 3
Show Answer & Explanation

Correct Answer: A — C89

C89 (ANSI C) is one of the official C language standards.

Q4.
Which of the following is NOT a keyword in C?
Aauto
Bregister
Cboolean
Dvolatile
Show Answer & Explanation

Correct Answer: C — boolean

C does not have a built-in boolean keyword.

Q5.
Which data type is used to store a single character?
Aint
Bchar
Cfloat
Ddouble
Show Answer & Explanation

Correct Answer: B — char

char data type is used to store a single character.

Q6.
What is the size of int data type in most 64-bit systems?
A2 bytes
B4 bytes
C8 bytes
DDepends on compiler
Show Answer & Explanation

Correct Answer: B — 4 bytes

On most modern systems, int occupies 4 bytes.

Q7.
Which modifier is used to increase the range of an integer?
Ashort
Blong
Csigned
Dconst
Show Answer & Explanation

Correct Answer: B — long

The long modifier increases the size/range of integer.

Q8.
Which qualifier makes a variable read-only?
Avolatile
Bregister
Cconst
Dstatic
Show Answer & Explanation

Correct Answer: C — const

const prevents modification of a variable.

Q9.
What is the default return type of main() in C?
Avoid
Bint
Cfloat
Dchar
Show Answer & Explanation

Correct Answer: B — int

By default, main() returns an integer value.

Q10.
Which header file is required for printf()?
Astdlib.h
Bconio.h
Cstdio.h
Dmath.h
Show Answer & Explanation

Correct Answer: C — stdio.h

printf() is declared in stdio.h.

Q11.
Which symbol is used to terminate a statement in C?
A:
B;
C.
D,
Show Answer & Explanation

Correct Answer: B — ;

Every C statement ends with a semicolon.

Q12.
Which of the following is a valid variable name?
A2num
B_num
Cfloat
Dnum-1
Show Answer & Explanation

Correct Answer: B — _num

Variable names can start with underscore.

Q13.
Which keyword is used to declare a constant?
Adefine
Bconst
Cstatic
Dvolatile
Show Answer & Explanation

Correct Answer: B — const

const keyword declares read-only variables.

Q14.
Which function is used to read formatted input?
Aprintf()
Bscanf()
Cgets()
Dputs()
Show Answer & Explanation

Correct Answer: B — scanf()

scanf() is used for formatted input.

Q15.
Which data type has the highest precision?
Afloat
Bdouble
Clong double
Dint
Show Answer & Explanation

Correct Answer: C — long double

long double provides highest floating-point precision.

Q16.

What is the output of the following code?


int x = 5;
printf("%d", x);
A5
B0
CGarbage
DError
Show Answer & Explanation

Correct Answer: A — 5

x is initialized to 5 and printed.

Q17.
Which of the following is NOT a basic data type?
Aint
Bfloat
Carray
Dchar
Show Answer & Explanation

Correct Answer: C — array

Array is a derived data type.

Q18.
Which keyword tells compiler not to optimize a variable?
Aconst
Bvolatile
Cstatic
Dextern
Show Answer & Explanation

Correct Answer: B — volatile

volatile prevents compiler optimizations.

Q19.
Which operator is used to get address of a variable?
A*
B&
C%
D#
Show Answer & Explanation

Correct Answer: B — &

& operator returns the address of a variable.

Q20.
Which of the following is true about C language?
AObject oriented
BPlatform dependent
CPlatform independent
DMarkup language
Show Answer & Explanation

Correct Answer: B — Platform dependent

C programs depend on underlying hardware and OS.

Q21.
Which of the following correctly prints an integer variable x?
Aprintf(%d, x);
Bprintf("%d", x);
Cprint(x);
Dscanf("%d", x);
Show Answer & Explanation

Correct Answer: B — printf("%d", x);

printf with %d format specifier is used to print integers.

Q22.
What is the size of char data type in C?
A1 byte
B2 bytes
C4 bytes
DDepends on compiler
Show Answer & Explanation

Correct Answer: A — 1 byte

char always occupies 1 byte in C.

Q23.
Which of the following is a correct declaration?
Aunsigned int x;
Bunsigned x int;
Cint unsigned x;
Dsigned float x;
Show Answer & Explanation

Correct Answer: A — unsigned int x;

Correct syntax is modifier followed by data type.

Q24.
Which keyword is used to store a variable in CPU register?
Aauto
Bstatic
Cregister
Dvolatile
Show Answer & Explanation

Correct Answer: C — register

register suggests the compiler to store variable in CPU register.

Q25.

What will be the output?


int a = 10;
printf("%d", sizeof(a));
A2
B4
C8
DDepends on system
Show Answer & Explanation

Correct Answer: B — 4

sizeof(int) is typically 4 bytes on modern systems.

Q26.
Which of the following is a valid constant?
A10
B10.5
C'A'
DAll of the above
Show Answer & Explanation

Correct Answer: D — All of the above

Integer, floating, and character constants are valid.

Q27.
Which escape sequence is used for new line?
A\t
B\n
C\r
D\b
Show Answer & Explanation

Correct Answer: B — \n

\n moves the cursor to next line.

Q28.

What is the output?


printf("Hello
World");
AHello World
BHelloWorld
CHello\nWorld
DHello then World in next line
Show Answer & Explanation

Correct Answer: D — Hello then World in next line

\n causes a line break.

Q29.
Which header file is needed for sizeof operator?
Astdio.h
Bstdlib.h
CNo header required
Dmath.h
Show Answer & Explanation

Correct Answer: C — No header required

sizeof is a compile-time operator.

Q30.
Which of the following is NOT allowed in variable names?
AAlphabets
BDigits
CUnderscore
DSpecial symbols
Show Answer & Explanation

Correct Answer: D — Special symbols

Special symbols like @, # are not allowed.

Q31.
Which keyword is used to declare global variables?
Aextern
Bstatic
Cauto
Dregister
Show Answer & Explanation

Correct Answer: A — extern

extern is used to declare global variables across files.

Q32.

What will be the output?


int x;
printf("%d", x);
A0
BGarbage value
CCompilation error
DRuntime error
Show Answer & Explanation

Correct Answer: B — Garbage value

Uninitialized local variables contain garbage values.

Q33.
Which data type is used to store decimal values?
Aint
Bfloat
Cchar
Dvoid
Show Answer & Explanation

Correct Answer: B — float

float stores decimal (fractional) values.

Q34.
Which of the following is true about volatile keyword?
APrevents modification
BPrevents optimization
CMakes variable global
DStores in register
Show Answer & Explanation

Correct Answer: B — Prevents optimization

volatile tells compiler value may change unexpectedly.

Q35.
Which operator is used to determine size of data type?
Asizeof
Blengthof
Csize
Dtype
Show Answer & Explanation

Correct Answer: A — sizeof

sizeof operator returns memory size in bytes.

Q36.
What is the correct format specifier for double?
A%f
B%lf
C%d
D%c
Show Answer & Explanation

Correct Answer: B — %lf

double uses %lf in scanf and printf.

Q37.
Which of the following is a correct comment in C?
A// comment
B/* comment */
C# comment
DBoth A and B
Show Answer & Explanation

Correct Answer: D — Both A and B

C supports both single-line and multi-line comments.

Q38.

What is the output?


printf("%c", 65);
A65
BA
CError
DGarbage
Show Answer & Explanation

Correct Answer: B — A

ASCII value 65 represents character 'A'.

Q39.
Which data type is used when function returns nothing?
Aint
Bnull
Cvoid
Dchar
Show Answer & Explanation

Correct Answer: C — void

void indicates no return value.

Q40.
Which of the following correctly ends the main function?
Astop;
Bexit;
Creturn 0;
Dbreak;
Show Answer & Explanation

Correct Answer: C — return 0;

return 0 indicates successful execution.