WorksheetsC programming for NEB
Total questions: 56
Worksheet time: 42mins
Who is the father of C language?
Steve Jobs
James Gosling
Dennis Ritchie
Rasmus Lerdorf
1. What will be the output of the following C code?
No Output
TESTING
Compiler error
None of the above
1. What will be the output of following program?
1 2 3 4 5
1 2 3 4
6
5
What will be the output of the program?
No Output
32 33 34
32 33 34 35
Compiler error
What is the purpose of a structure in C programming?
It is used to define a new data type that can contain different types of variables.
It is a type of function in C programming.
It is a keyword used for conditional statements in C programming.
It is a type of loop in C programming.
What is the correct operator to access elements of a structure using pointers in C programming?
Use the dot operator (.)
Use the asterisk operator (*)
Use the hash operator (#)
Use the arrow operator (->)
What is the purpose of using an array within a structure in C programming?
To allow for storing multiple elements of different data types within a single structure.
To restrict the structure to store only a single element of a specific data type.
To prevent access to the array within the structure using index notation.
To enable storing multiple elements of the same data type within a single structure.
Which of the following is the correct syntax for declaring an array of structures in C programming?
student[10] struct;
int student[10];
struct student students[10];
struct students[10];
How do you declare a pointer to a structure in C programming?
struct *ptrName = structureName;
ptrName = &structureName;
struct structureName *ptrName;
struct ptrName = &structureName;
What are the member variables of the 'Student' structure?
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.
The member variables of the 'Student' structure are not necessary in a C program
The member variables of the 'Student' structure are only limited to integers
The member variables of the 'Student' structure are always name, age, and gender
How do you access the member variables of a structure in C?
Using the asterisk (*) operator
Using the dot (.) operator
Using the hash (#) operator
Using the plus (+) operator
What are the advantages of using structures in C programming?
Structures are not supported in C programming.
Structures make the code more difficult to read and understand.
Structures cannot contain variables of different data types.
Structures allow for the creation of complex data types by grouping together variables of different data types.
How do you declare a structure variable of type 'Student' in C?
struct Student student1;
Student = student1;
int student1;
Student student1;
Explain the concept of nested structures in C programming.
Arrays within a structure
Functions within a structure
Structures within a structure
Loops within a structure
What are the limitations of structures in C programming?
Inability to contain methods or functions, lack of inheritance, and inability to hide data
Ability to contain methods and functions
Presence of inheritance
Ability to hide data
Discuss the use of typedef with structures in C.
Typedef with structures in C allows for creating an alias name for the variable.
Typedef with structures in C allows for creating an alias name for the structure type.
Typedef with structures in C is used to define the size of the structure.
Typedef with structures in C is only applicable to arrays.
What symbol is used to declare a pointer variable in C?
*
&
%
#
Which of the following is a valid struct declaration?
struct Person { char name; int age; }
struct Person: { char name[50]; int age; };
struct Person { char name[50]; int age; };
struct Person { char name[50]; int age; }[];
What does the '->' operator do in C?
Accesses members of a structure through a pointer
Declares a pointer
Defines a new variable
Creates a new structure
What is the output of 'printf("Salary: %.2f", person1.salary);' if salary is 2500?
Salary: 2500.000
Salary: 2500.0
Salary: 2500
Salary: 2500.00
Which of the following is NOT a valid member operator in C?
[]
->
++
.
What does the term 'pointer to a pointer' refer to?
A pointer that points to an array
A pointer that points to a function
A pointer that points to another pointer
A pointer that points to an integer
In the struct definition, what does the following line represent: 'char name[50];'?
An integer variable
A floating-point variable
An array of characters
A pointer to a string
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);
}
Run time error
Nothing
hello
Varies
What is meaning of below lines?
void sum (int, int);
sum is a function which takes two int arguments and returns void
sum is function which takes int arguments
it will produce compilation error
Can't comment.
Which of the following is a complete correct function definition?
int funct();
int funct(int x){ x = x +1; return x; }
void funct(int){ printf( “Hello”);
void funct(x){ printf( “Hello”); }
Any C Program must contain
Must contain at least one function.
Need not contain any function.
Needs input data.
None of the above
Use of functions
Helps to avoid repeating a set of statements many times.
Enhances the logical clarity of the program.
Helps to avoid repeated programming across programs
Makes the debugging task easier.
All of the above
What is function?
Function is a block of statements that perform some specific task.
Function is the fundamental modular unit. A function is usually designed to perform a specific task.
Function is a block of code that performs a specific task. It has a name and it is reusable.
All of the above
Find error/ output in following code
Void fn ()
{
Static int i= 10;
Printf ( " %d " , ++i );
}
int main ()
{
fn();
fn();
}
10 10
11 12
11 11
12 12
void function () { }
function [] { }
How many values can a C Function return at a time.?
Only One Value
Maximum of two values
Maximum of three values
Maximum of 8 values
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;
}
TIGER COUNT=15
TIGER COUNT=35
TIGER COUNT=0
Compiler error
Which of the following is true about return type of functions in C?
Functions can return any type
Functions can return any type except array and functions
Functions can return any type except array, functions and union
Functions can return any type except array, functions, function pointer and union
In C, what is the meaning of following function prototype with empty parameter list
void fun()
{
/* .... */
}
Function can only be called without any parameter
Function can be called with any number of parameters of any types
Function can be called with any number of integer parameters.
Function can be called with one integer parameter
What is the output of this C code?
int main()
{
void foo(), f();
f();
}
void foo()
{
printf("2 ");
}
void f()
{
printf("1 ");
foo();
}
Compile time error as foo is local to main
1 2
2 1
Compile time error due to declaration of functions inside main
The function name and the parameter list together constitute the ---------------
function signature
main function
input function
output function
The parameter list in main function represent ---- parameter
formal parameter
argument list
actual parameter
parameter list
