Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C programming for NEB

Total questions: 56

Worksheet time: 42mins

Name
Class
Date
1.

Who is the father of C language?

a)

Steve Jobs

b)

James Gosling

c)

Dennis Ritchie

d)

Rasmus Lerdorf

2.

1. What will be the output of the following C code?

a)

No Output

b)

TESTING

c)

Compiler error

d)

None of the above

3.

1. What will be the output of following program?

a)

1 2 3 4 5

b)

1 2 3 4

c)

6

d)

5

4.

What will be the output of the program?

a)

No Output

b)

32 33 34

c)

32 33 34 35

d)

Compiler error

5.

What is the purpose of a structure in C programming?

a)

It is used to define a new data type that can contain different types of variables.

b)

It is a type of function in C programming.

c)

It is a keyword used for conditional statements in C programming.

d)

It is a type of loop in C programming.

6.

What is the correct operator to access elements of a structure using pointers in C programming?

a)

Use the dot operator (.)

b)

Use the asterisk operator (*)

c)

Use the hash operator (#)

d)

Use the arrow operator (->)

7.

What is the purpose of using an array within a structure in C programming?

a)

To allow for storing multiple elements of different data types within a single structure.

b)

To restrict the structure to store only a single element of a specific data type.

c)

To prevent access to the array within the structure using index notation.

d)

To enable storing multiple elements of the same data type within a single structure.

8.

Which of the following is the correct syntax for declaring an array of structures in C programming?

a)

student[10] struct;

b)

int student[10];

c)

struct student students[10];

d)

struct students[10];

9.

How do you declare a pointer to a structure in C programming?

a)

struct *ptrName = structureName;

b)

ptrName = &structureName;

c)

struct structureName *ptrName;

d)

struct ptrName = &structureName;

10.

What are the member variables of the 'Student' structure?

a)

The member variables of the 'Student' structure will depend on how it is defined in the C program, and can include attributes such as name, age, roll number, and marks.

b)

The member variables of the 'Student' structure are not necessary in a C program

c)

The member variables of the 'Student' structure are only limited to integers

d)

The member variables of the 'Student' structure are always name, age, and gender

11.

How do you access the member variables of a structure in C?

a)

Using the asterisk (*) operator

b)

Using the dot (.) operator

c)

Using the hash (#) operator

d)

Using the plus (+) operator

12.

What are the advantages of using structures in C programming?

a)

Structures are not supported in C programming.

b)

Structures make the code more difficult to read and understand.

c)

Structures cannot contain variables of different data types.

d)

Structures allow for the creation of complex data types by grouping together variables of different data types.

13.

How do you declare a structure variable of type 'Student' in C?

a)

struct Student student1;

b)

Student = student1;

c)

int student1;

d)

Student student1;

14.

Explain the concept of nested structures in C programming.

a)

Arrays within a structure

b)

Functions within a structure

c)

Structures within a structure

d)

Loops within a structure

15.

What are the limitations of structures in C programming?

a)

Inability to contain methods or functions, lack of inheritance, and inability to hide data

b)

Ability to contain methods and functions

c)

Presence of inheritance

d)

Ability to hide data

16.

Discuss the use of typedef with structures in C.

a)

Typedef with structures in C allows for creating an alias name for the variable.

b)

Typedef with structures in C allows for creating an alias name for the structure type.

c)

Typedef with structures in C is used to define the size of the structure.

d)

Typedef with structures in C is only applicable to arrays.

17.

What symbol is used to declare a pointer variable in C?

a)


*

b)

&

c)

%

d)


#

18.

Which of the following is a valid struct declaration?

a)

struct Person { char name; int age; }

b)

struct Person: { char name[50]; int age; };

c)

struct Person { char name[50]; int age; };

d)

struct Person { char name[50]; int age; }[];

19.

What does the '->' operator do in C?

a)

Accesses members of a structure through a pointer

b)

Declares a pointer

c)

Defines a new variable

d)

Creates a new structure

20.

What is the output of 'printf("Salary: %.2f", person1.salary);' if salary is 2500?

a)

Salary: 2500.000

b)

Salary: 2500.0

c)

Salary: 2500

d)

Salary: 2500.00

21.

Which of the following is NOT a valid member operator in C?

a)

[]

b)

->

c)

++

d)

.

22.

What does the term 'pointer to a pointer' refer to?

a)

A pointer that points to an array

b)

A pointer that points to a function

c)

A pointer that points to another pointer

d)

A pointer that points to an integer

23.

In the struct definition, what does the following line represent: 'char name[50];'?

a)

An integer variable

b)

A floating-point variable

c)

An array of characters

d)

A pointer to a string

24.

What will be the output of the following C code?


#include <stdio.h>

struct student

{

char *c;

};


void main()

{

struct student m;

struct student *s = &m;

s->c = "hello";

printf("%s", m.c);

}

a)

Run time error

b)

Nothing

c)

hello

d)

Varies

25.
When a variable is created in C, a memory address is assigned to the variable.
a)
True
b)
False
26.
When a variable is created in C, a memory address is assigned to the variable.
a)
True
b)
False
27.
In C, code statements must end with a semicolon (;)
a)
True
b)
False
28.
How can you create a variable with the numeric value 5?
a)
num = 5;
b)
val num = 5;
c)
val num = 5;
d)
int num = 5;
29.
How can you create a variable with the floating number 2.3?
a)
num = 2.3 float;
b)
float num = 2.3;
c)
num = 2.3 double;
d)
val num = 2.3;
30.
Which operator is used to add together two values?
a)
The * sign
b)
The + sign
c)
The ADD keyword
d)
The & sign
31.
Which function is often used to output values and print text?
a)
output()
b)
printf()
c)
write()
d)
printword()
32.
Which format specifier is often used to print integers?
a)
%f
b)
%d
c)
%c
d)
%s
33.
Which operator can be used to compare two values?
a)
<>
b)
><
c)
=
d)
==
34.
Which operator can be used to find the memory size (in bytes) of a data type or variable?
a)
The sizer property
b)
The sizeof property
c)
The len property
d)
The length property
35.
How do you start writing an if statement in C?
a)
if x>y
b)
if (x>y)
c)
if x>y()
d)
if x>y then
36.
How do you start writing a for loop in C?
a)
int i; for (i=0; i<5; i++)
b)
for (int i=0; I i++; i+=1)
c)
int i; for (i=0; with i<5; i++)
d)
int i; for (i=0; while i<5; i++)
37.
Which statement can be used to select one of many code blocks to be executed?
a)
break
b)
when
c)
switch
d)
default
38.
Which statement is used to stop a loop?
a)
break
b)
stop
c)
void
d)
exit
39.
Functions cannot return more than one value at a time
a)
True
b)
False
40.
In C all functions except main() can be called recursively.
a)
True
b)
False
41.

What is meaning of below lines?

void sum (int, int);

a)

sum is a function which takes two int arguments and returns void

b)

sum is function which takes int arguments

c)

it will produce compilation error

d)

Can't comment.

42.
Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others.
a)
Yes
b)
No
43.

Which of the following is a complete correct function definition?

a)

int funct();

b)

int funct(int x){ x = x +1; return x; }

c)

void funct(int){ printf( “Hello”);

d)

void funct(x){ printf( “Hello”); }

44.

Any C Program must contain

a)

Must contain at least one function.

b)

Need not contain any function.

c)

Needs input data.

d)

None of the above

45.

Use of functions

a)

Helps to avoid repeating a set of statements many times.

b)

Enhances the logical clarity of the program.

c)

Helps to avoid repeated programming across programs

d)

Makes the debugging task easier.

e)

All of the above

46.

What is function?

a)

Function is a block of statements that perform some specific task.

b)

Function is the fundamental modular unit. A function is usually designed to perform a specific task.

c)

Function is a block of code that performs a specific task. It has a name and it is reusable.

d)

All of the above

47.

Find error/ output in following code

Void fn ()

{

Static int i= 10;

Printf ( " %d " , ++i );

}

int main ()

{

fn();

fn();

}

a)

10 10

b)

11 12

c)

11 11

d)

12 12

48.
Which one is a function prototype?
a)
void function ();
b)
function ();
c)
void function [];
d)
() function { };
49.
Which function is correct?
a)

void function () { }

b)

function [] { }

c)
function ( { } )
d)
void function [ ] ( )
50.

How many values can a C Function return at a time.?

a)

Only One Value

b)

Maximum of two values

c)

Maximum of three values

d)

Maximum of 8 values

51.

What is the output of C Program with functions.?


void main()

{

int a;

printf("TIGER COUNT=");

a=show();

printf("%d", a);

}


int show()

{

return 15;

return 35;

}

a)

TIGER COUNT=15

b)

TIGER COUNT=35

c)

TIGER COUNT=0

d)

Compiler error

52.

Which of the following is true about return type of functions in C?

a)

Functions can return any type

b)

Functions can return any type except array and functions

c)

Functions can return any type except array, functions and union

d)

Functions can return any type except array, functions, function pointer and union

53.

In C, what is the meaning of following function prototype with empty parameter list

void fun()

{

/* .... */

}

a)

Function can only be called without any parameter

b)

Function can be called with any number of parameters of any types

c)

Function can be called with any number of integer parameters.

d)

Function can be called with one integer parameter

54.

What is the output of this C code?


int main()

{

void foo(), f();

f();

}

void foo()

{

printf("2 ");

}

void f()

{

printf("1 ");

foo();

}

a)

Compile time error as foo is local to main

b)

1 2

c)

2 1

d)

Compile time error due to declaration of functions inside main

55.

The function name and the parameter list together constitute the ---------------

a)

function signature

b)

main function

c)

input function

d)

output function

56.

The parameter list in main function represent ---- parameter

a)

formal parameter

b)

argument list

c)

actual parameter

d)

parameter list