0% found this document useful (0 votes)
6 views4 pages

VIVA QUESTIONS

The document contains a series of questions and answers related to the C programming language, covering topics such as data types, functions, control structures, pointers, and input/output operations. It provides concise definitions and explanations for each concept, including examples of usage. The content serves as a study guide for understanding fundamental C programming concepts.

Uploaded by

balajinatpi2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

VIVA QUESTIONS

The document contains a series of questions and answers related to the C programming language, covering topics such as data types, functions, control structures, pointers, and input/output operations. It provides concise definitions and explanations for each concept, including examples of usage. The content serves as a study guide for understanding fundamental C programming concepts.

Uploaded by

balajinatpi2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

VIVA QUESTIONS

What are the basic data types in C?


int, float, double, and char.
What is the size of an int on a 32-bit system?
4 bytes.
What is the difference between float and double?
double provides higher precision than float.

What is the size of a char in C?


1 byte.

What is a ternary operator?


A shorthand for if-else using condition ? expr1 : expr2.

What is the void data type?


A type that represents no value or no data.

What are derived data types?


Arrays, pointers, structures, and unions.

What are functions in C?


Functions are blocks of code that perform specific tasks and can be reused.

What is a library function?


Predefined functions provided by C, like printf() and scanf().

What is a user-defined function?

A function created by the programmer to perform specific tasks.

What is recursion?
A function that calls itself.

What is an array in C?
A collection of elements of the same data type stored in contiguous memory.

What is the index of the first element in an array?


Zero (0).

How do you declare a 2D array in C?


data_type array_name[rows][columns];

What is a structure in C?
A user-defined data type that groups variables of different types.
Can structures contain arrays?
Yes, structures can contain arrays as members.

What is a union in C?
A user-defined data type where all members share the same memory location.

What is the difference between structure and union?


In a structure, each member has its memory, but in a union, all members share
the same memory.

What is the purpose of the main() function?


It is the entry point of a C program.

What is the difference between break and continue?


break exits the loop, while continue skips the current iteration.

What does #include<stdio.h> do?


It includes the standard input-output library in the program.

What is the difference between while and do-while loops?


while checks the condition first; do-while executes the loop at least once.

What is a null character in C?


'\0', used to terminate strings.

What is the use of the sizeof operator?


It returns the size of a variable or data type in bytes.

What are preprocessor directives?


Commands that are processed before compilation, like #define and #include.

What is the purpose of the return statement?


It exits a function and optionally returns a value.

What is a file in C?
A storage area in memory or disk used for storing data permanently.

What is dynamic memory allocation?


Allocating memory at runtime using functions like malloc and calloc.

What is the difference between the local and global variables in C?

Local variables are declared inside a block or function but global variables are
declared outside the block or function to be accessed globally.
What are pointers?

Pointers are used to store the address of the variable or a memory location

Conditional Statements

1. What is the purpose of an if statement?


It executes a block of code if a specified condition is true.
2. What is the difference between if-else and else-if ladder?
if-else handles a single condition, while the else-if ladder evaluates
multiple conditions sequentially.
3. Can we write if without else?
Yes, else is optional.
4. What is a nested if statement?
An if statement inside another if statement.
5. What is a switch-case statement?
A multi-way branching statement used as an alternative to if-else-if.

Loops

1. What are the types of loops in C?


for, while, and do-while.
2. What is the difference between for and while loops?
for is used when the number of iterations is known; while is used
when the condition is evaluated dynamically.
3. Can we use a break statement in a loop?
Yes, it is used to exit the loop prematurely.
4. What is an infinite loop?
A loop that never terminates because the condition is always true.
5. What is the purpose of the continue statement?
It skips the current iteration and proceeds to the next.
6. What is a nested loop?
A loop inside another loop.

Pointers

1. What is a pointer?
A variable that stores the address of another variable.
2. What is the difference between * and & in pointers?
* dereferences a pointer, and & gets the address of a variable.
3. What is a null pointer?
A pointer that does not point to any memory location.

Input/Output
1. What is the purpose of scanf()?
It reads input from the user.
2. What is printf() used for?
It displays output to the console.
3. Can we use scanf() for strings?
Yes, using %s format specifier.

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