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

Pps 2m Answers

The document provides an overview of fundamental concepts in C programming, including the purpose of the main function, basic data types, and the importance of linking and definition sections. It also covers operators, variable definitions, arrays, structures, pointers, functions, recursion, dynamic memory allocation, and various sorting techniques. Additionally, it discusses the differences between linear and binary search, as well as advantages of loops and functions.

Uploaded by

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

Pps 2m Answers

The document provides an overview of fundamental concepts in C programming, including the purpose of the main function, basic data types, and the importance of linking and definition sections. It also covers operators, variable definitions, arrays, structures, pointers, functions, recursion, dynamic memory allocation, and various sorting techniques. Additionally, it discusses the differences between linear and binary search, as well as advantages of loops and functions.

Uploaded by

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

1. What is the purpose of main () function in C?

Ans:-Every C program has a primary function that must be named main . The main
function serves as the starting point for program execution.

2. List the basic datatypes in C?

Ans:-The C language provides the four basic arithmetic type specifiers char, int, float and
double, and the modifiers signed, unsigned, short, and long.

3. What is the importance of Linking and Definition section in C?

Ans:-The link and definition sections are called as preprocessor directives. It gives instructions to the
compiler to link function from the system library.

4) Describe the difference between = and = = operators in C?

Ans:-= is an Assignment Operator in C, C++ and other programming languages, It is Binary


Operator which operates on two operands.

== is an Equal To Operator in C and C++ only, It is Binary Operator which operates on two operands

5) Define Variable with syntax? Give an example?

Ans:- You can define a variable as an integer and assign a value to it in a single declaration. For
example: int age = 10; In this example, the variable named age would be defined as an integer and
assigned the value of 10.19

6 Differentiate between compiler and interpreter ?

Ans:- Compiler: A compiler translates code from a high-level programming language into machine
code before the program runs.

Interpreter: An interpreter translates code written in a high-level programming language into


machine code line-by-line as the code runs.

7 Define multidimensional array? List the advantages of Arrays?

Ans:- A multi-dimensional array is an array with more than one level or dimension.

Advantages: ➢ It is used to represent multiple data items of same type by using only single name.

➢ It can be used to implement other data structures like linked lists, stacks,
queues ,trees, graphs etc.

➢ Multidimensional arrays are used to represent matrices.

8 Distinguish between String & Character ?

Ans:- Strings are sequences of characters enclosed in double quotes, used for handling text and
varying in length.

Characters, represented by single symbols in single quotes, are primitive data types primarily used
for storing and manipulating individual symbols.

9 Define Structure with syntax?


Ans:- Structures (also called structs) are a way to group several related variables into one place. Each
variable in the structure is known as a member of the structure. Unlike an array, a structure can
contain many different data types (int, float, char, etc.).

10 What are the advantages of loops?

Ans:- 1) It provides code reusability.

2) Using loops, we do not need to write the same code again and again.

3) Using loops, we can traverse over the elements of data structures

11 List the types of conditional statements.


Ans:- There are four types of conditional statements:
 If condition.
 If-else condition.
 Nested if-else.
 If-else ladder.

12 Define Union with syntax?

Ans:- The syntax for using the union keyword to define union is similar to that of constructing a
structure.

13 Define Pointer? List the types of pointers.


Ans:- A pointer is a variable whose value is the address of another variable of the same type. The
value of the variable that the pointer points to by dereferencing using the * operator. The different
types of pointers are void, null, dangling, wild, near, far, huge.

14 What is the use of pointers in Self-referential Structures.


Ans:- The pointer points to a variable of the same type, allowing the structure to refer to
itself and creating a linked structure. In C, a self-referential structure is a structure that
contains a pointer to a variable of the same type. This allows the structure to refer to itself,
creating a linked data structure.
15 Discuss the advantages of Pointers?
Ans:- Pointers provide direct memory access, enabling efficient manipulation of data. They
allow for dynamic memory allocation, making it possible to create flexible and memory-
efficient programs
16 Write the syntax of open().
Ans:- C Library - fopen() function. The C library function FILE *fopen(const char
*filename, const char *mode) opens the filename pointed to, by filename using the given
mode. It opens a file and returns a pointer to a FILE object that can be used to access the file.
17 Write the syntax of fseek() function.
Ans:- fseek() The fseek() function is used for setting the file pointer at the specific position in the file.
Here is its syntax: fseek(FILE *file_pointer, long int offset, int location);

18 Define a function? List the advantages of functions.

Ans:- The function can reduce the repetition of the same statements in the program

Advantage:> Functions make a program more readable

> The function can be reused countless times after it is defined.

19 What is the Function signature in C?


Ans:- A function signature consists of the functions name and number of, order of, type of
parameters used.

20 List the types of Storage classes in C.

Ans:- The four main storage classes in C are automatic (auto), external (extern), static (static), and
register (register).

21 Define Recursion? What are the limitations of functions.

Ans:- Recursion means a function calls repeatedly. It uses system stack to accomplish its task.

22 What is the advantage of Dynamic Memory Allocation?

Ans:- Advantages of Dynamic Memory allocation

>This allocation method has no memory wastage.

> The memory allocation is done at run time.

> Memory size can be changed based on the requirements of the dynamic memory allocation.

> If memory is not required, it can be freed.

23 List some standard library functions?

Ans:-

Function

fopen

fprintf

fputc1

fputs1

24 Tell the advantage of Linear Search?


Ans:- With today's powerful computers, small to medium arrays can be searched relatively
quickly.
25 What is the Time complexity of Bubble sort in best case?
Ans:- The worst-case time complexity of Bubble Sort is O(n^2), and the best-case time
complexity is O(n), which occurs when the input list is already sorted.
26 What is the Time complexity of Binary search in best case?
Ans:- In this case, the algorithm can determine the target element in the first comparison and
return the index immediately. The best-case time complexity of binary search is O(1), indicating
constant time complexity.
27 Compare Linear search and Binary search?
Ans:- Linear Search sequentially checks each element in the list until it finds a match or
exhausts the list.
Binary Search continuously divides the sorted list, comparing the middle element with the
target value.

28 Compare selection sort and insertion sort?


Ans:- Insertion Sort sequentially inserts elements into a sorted subarray, whereas
Selection Sort finds and places the smallest element in each iteration, generally resulting in
fewer swaps.

29List out Sorting Techniques?


Ans:- >Bubble sort
>Selection sort
>Insertion sort
>Merge sort
>Quick sort
>Counting sort
>Radix sort
>Bucket sort

You might also like