0% found this document useful (0 votes)
16 views15 pages

C Programming Course Overview and Exercises

The document is a question bank for a Computer Programming C course at the World College of Engineering, covering various topics such as control structures, functions, and data types. It includes both theoretical questions and practical programming exercises, along with examples and explanations of C programming concepts. The content is structured into units and parts, with specific questions designated for different examination periods.

Uploaded by

Banupriya M
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)
16 views15 pages

C Programming Course Overview and Exercises

The document is a question bank for a Computer Programming C course at the World College of Engineering, covering various topics such as control structures, functions, and data types. It includes both theoretical questions and practical programming exercises, along with examples and explanations of C programming concepts. The content is structured into units and parts, with specific questions designated for different examination periods.

Uploaded by

Banupriya M
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

STUDY WORLD COLLEGE OF ENGINEERING

(Approved by AICTE &Affiliated to Anna University, Chennai)


Coimbatore - 641105
ACADEMIC FORMATS
QUESTIONBANK

DEPARTMENT OF SCIENCE AND HUMANTIES

Course Code : CS25C01


Course Name : COMPUTER PROGRAMMING C
Regulation : 2025
Year/Sem : I/I
Faculty Incharge :

UNIT I
Introduction to C & Control Structures
Problem Solving, Problem Analysis Chart, Developing an Algorithm, Flowchart and
Pseudocode, program structure, Compilation & Execution process, Interactive and Script
mode, Comments, Indentation, Error messages, Primitive data types, Constants,
Variables, Reserved words, Arithmetic, Relational, Logical, Bitwise, Assignment,
Conditional operators, Input/Output Functions, Built-in Functions.

PART-A

1. #include <stdio.h>
int main() {
printf("Hello World %d\n", x);
return 0;
}
write the output of the program? (Apr/May 2025)

The program gives a compilation error due to the undeclared variable x


2. #include <stdio.h>
int main()
{
int j = 1;
while (j <= 255)
{
printf("%c %d\n", j, j);
j++;
}
return 0;
}
Write the output of the above program? (Apr/May 2025)

The program prints all ASCII characters (1–255) along with their decimal [Link]
! - 33, " - 34, # - 35, $ - 36, % - 37, & - 38.

3. Write any two applications of C language. (Nov/Dec-2024)

1) Operating Systems – C is used to develop operating systems like UNIX,


Windows, and Linux kernel.
2) Embedded Systems – C is widely used in microcontrollers, IoT devices, and
robotics.

4. Differentiate while and Do-While Loop statements. (Nov/Dec-2024)

1) In while loop, condition is checked first, so the loop may not execute at all.
2) In do-while loop, condition is checked after execution, so the loop runs at least
once.

5. List at least any ten keywords in C language?(APR/MAY 2024)


1) int
2) float
3) double
4) char
5) return
6) if
7) else
8) while
9) for
10) void
6. What is the output of the following program? (APR/MAY 2024)
#include<stdio.h>
int main()
{
int I;
I=1,2,3;
printf(“%d”,I);
Retuen 0;
}
The output of the program will be : 1

7. "Keywords cannot be used as Identifiers" - Justify the correctness of the


statement.(NOV/DEC 2023)
In C, keywords are reserved words with predefined meanings, such as int, if, for, and return.
These words are essential for the language's syntax and functionality. Since keywords are already
defined by the language, they cannot be used as identifiers (names for variables, functions, etc.).
Using a keyword as an identifier would cause a syntax error because it conflicts with the
language's structure.
Condition Check Condition is Condition is
checked before executing the checked after executing the
8. loop body. loop body.
First Execution If the condition is false The loop body is
initially, the loop body is not always executed at least once.
executed.
Syntax while (condition) { // code } do { // code } while
(condition);
Example int i = 0; int i = 0;
while (i < 3) { do {
printf("%d ", printf("%d ", i);
i); i++;
i++; } while (i < 3);
}
Output 012 012
Use Case Used when the number of Used when the loop should
iterations is unknown, but the execute at least once, even if
condition should be checked the condition is false initially.
first.
D
istinguish between 'While' and 'Do-While' looping constructs with one example. (NOV/DEC
2023)

9. Draw the structure of C program.(APR/MAY 2023)


#include <stdio.h> // Preprocessor directive
// Function prototypes (optional)
// Global variables (optional)
int main() { // Main function
// Local variables
// Code statements
return 0; // Return statement
}
// User-defined functions (optional)

10. What is the purpose of format specifier in 1/O statements? Give an example. (APR/MAY
2023)
Purpose: Format specifiers are used to specify the type of data to be input or output.
Example:
int num = 5;
printf("Number: %d", num); // %d is the format specifier for integers
11. What are the various types of operators? (NOV/DEC 2022)
The types of operators in C include:
Arithmetic Operators: +, -, *, /, %
Relational Operators: ==, !=, <, >, <=, >=
Logical Operators: &&, ||, !
Bitwise Operators: &, |, ^, ~, <<, >>
Assignment Operators: =, +=, -=, *=, /=
Increment/Decrement Operators: ++, --
Conditional (Ternary) Operator: ? :
Pointer Operators: &, *

12. What is the use of preprocessor directive?(NOV/DEC 2022)


Preprocessor directives are used to provide instructions to the compiler before the actual
compilation starts. They are used for tasks like file inclusion (#include), defining constants
(#define), and conditional compilation (#if, #ifdef).
13. Write short notes on Keywords in C language.(APR/MAY 2022)
Keywords in C are reserved words with predefined meanings that cannot be used as identifiers.
They are used to define the syntax and structure of the program. Examples include int, if, while,
return, for, etc.
14. What is difference between the statements a = 5 and a = 5 in language C? (APR/MAY 2022)
The two statements are identical. In C, a = 5 is an assignment statement that assigns the value 5 to
the variable a. There is no difference in the expression itself.

PART-B
1. (i) Write a C program using while loop to reverse the digits of the number.
(ii) Discuss about the various data types in C with an example. (APR/MAY 2025)
2. (i) Write a C program to check whether the person is eligible for voting using if/else.
(ii) Explain operators and operator precedence in C with an example. (APR/MAY
2025)
3. (i) Write a C program to check whether the person is eligible for voting using if/else.
(ii) Write a C program to print the grade of student using switch statement.
(NOV/DEC 2024)
4. (i) Write a structure of a C program.
(ii) Explain the preprocessor directives in C programming. (NOV/DEC 2024)
5. (i)Discuss the structure of C program in detail and explain with simple hello world
program.
(ii)Explain the terms variables and constants. How many types of variables are
supported by C. (APR/MAY 2024)
6. (i)What is purpose of Decision Control Statements in C? Explain any two of such
types with the general form of simple statements.
(ii) What are the functionalities of Preprocessor and Compiler? Explain with a simple
example. (APR/MAY 2024)
7. (i)Evaluate the following expressions using operator precedence rule.
Explain the order of execution of operators.
(8*3-4)+(5%5? 3 : -9) + 5 - 20 / 10
a * b + (c / d) - 2 ^ 2 - (e + 4) where a = 2, b = 3, c = 8,d = 2, e = 5.
(ii) Elaborate the various Data types in C with suitable examples. (NOV/DEC 2023)
8. (i)Find the output of the following C code. Discuss the steps of execution.(4)
for (1=1,j=1; i<=10; ++i, ++j)
{
if (i == 3) { continue;}
else {
if (j== 4) {break;}
else {
printf("\ I am in loop, the values of I and J are: %d, %d", I,j);
}
}
}
(ii)Write a C program to get age and vaccination detail as input. Print "Senior Citizen
and Eligible for Booster" if age > 60 and vaccination input as '2. Otherwise print
"Below 60, and Eligible for Vaccination". Use Conditional Operator.
(iii) Is it possible to convert 'if-else' ladder to 'switch....case' statement? If yes,
illustrate with an example. If no, justify the reason. (NOV/DEC 2023)
9. Explain the various data types being supported by C language. (APR/MAY 2023)
10. Explain about the various looping statements available in 'C' with appropriate sample
programs. (APR/MAY 2023)
11. Explain the storage classes in 'C with suitable examples. (NOV/DEC 2022)
12. Explain the looping statement in C with suitable examples. (NOV/DEC 2022)
13. Draw the structure of a C program and explain each part in detail. (APR/MAY 2022)
14. Enumerate the difference between 'else-if ladder' and 'switch - case' statements with
appropriate C programs. (APR/MAY 2022)

UNIT II
Control Structures & Functions
if, if-else, nested if, switch-case, while, do-while, for, nested loops, Jump statements.
Function Declaration, Definition and Calling, Function Parameters and Return Types, Call
by Value and Call by Reference, Recursive Functions, Scope and Lifetime of Variables,
Header files and Modular Programming.

PART-A

1. Write the string function to remover the space at the start and end of a given string?
(Apr/May-2025)
void trim(char *str) {
char *start = str;
char *end;
while (*start && isspace((unsigned char)*start))
start++;
if (*start == 0) {
str[0] = '\0';
return;
}
end = start;
while (*end)
end++;
end--;
while (end > start && isspace((unsigned char)*end))
end--;
*(end + 1) = '\0';
if (start != str) {
while (*start)
*str++ = *start++;
*str = '\0';
}
}
2. String f = "programming in c“
write the syntax to find the length of the string with out using build in function (Apr/May-
2025)
#include <stdio.h>
int main() {
char f[] = "programming in c";
int length = 0;
while (f[length] != '\0') {
length++;
}
printf("Length of the string: %d\n", length);
return 0;
}
3. If String 1="C Programming" and String 2="Language"; Write the built-in functions to
(NOV/DEC 2024)
a. Find the length of the String 1 ;
b. Compare two strings. Whether they are equal.
To find the length of String 1:
int len = strlen(String1);
To compare two strings:
int result = strcmp(String1, String2);
4. What will happen if in a C program you assign a value to an array element whose subscript
exceeds the size of array? (NOV/DEC 2024)

If you assign a value to an array element whose subscript exceeds the array's size, it leads
to undefined behavior (accessing memory outside the allocated array).
5. What is the output of the following code (APR/MAY 2024)
int main()
int a [4] = {1, 2, 3, 4};
a++;
printf("%d", *a);
return 0;
}

The output of the program is 2

6. What will be the value of var for the following String Operations statement in C language?
(APR/MAY 2024)
var = stremp ("Hello", "World");
The function strcmp("Hello", "World") compares two strings. Since "Hello" is lexicographically
less than "World", it returns a negative value (usually -1). Thus, var will hold a negative value.
7. Give an example for initialization of a 2D array with a set of values. (NOV/DEC 2023)
int arr[3][2] = {
{1, 2},
{3, 4},
{5, 6}
};
8. Write any two string handling functions in C with their syntax and purpose. (NOV/DEC
2023)
strlen():
Syntax: size_t strlen(const char *str);
Purpose: Returns the length of the string excluding the null terminator.
strcpy():
Syntax: char *strcpy(char *dest, const char *src);
Purpose: Copies the string from src to dest.
9. Write down the syntax and give an example for array initialization. (APR/MAY 2023)
Syntax: data_type array_name[size] = {values};
Example:
int arr[3] = {1, 2, 3};

10. How to identify the length of a string? (APR/MAY 2023)


Answer: Use the strlen() function to find the length of a string (excluding the null character).
Example:
char str[] = "Hello";
printf("%lu", strlen(str));
Output: 5

11. Declare a float array of size 5 and assign 5 values to it. (NOV/DEC 2022)
float arr[5] = {1.1, 2.2, 3.3, 4.4, 5.5};
12. Sort the following elements using selection sort method 23,55, 16, 78, 2. (NOV/DEC 2022)
Selection Sort Algorithm:
Find the minimum and swap with the first element: [2, 55, 16, 78, 23]
Find the next minimum and swap with the second element: [2, 16, 55, 78, 23]
Continue the process: [2, 16, 23, 78, 55]
Final sorted array: [2, 16, 23, 55, 78]
13. Write down the syntax for array declaration. (APR/MAY 2022)
The syntax for declaring an array in C is:
data_type array_name[size];
Example:
int arr[5]; // Array of 5 integers
14. What is the purpose and prototype of the function 'stropy? (APR/MAY 2022)
 strcpy() is used to copy a string from one location to another.
 Prototype:
char *strcpy(char *dest, const char *src);

PART-B

1. (i) C program to find maximum among a set of numbers


(ii) C program to perform matrix multiplication? (Apr/May-2025)

2. (i) Write a C program to sort the given List: {5,1,78,9,34,14} using selection sort.
(ii) Write a C program to compare and concatenate the following strings without
using built-in functions
String S1 = "Computer"; String S2 = "Fundamentals"; (Apr/May-2025)

3. Write a program using array to read and display the information about
an employee and also calculate the payroll of an employee. (NOV/DEC 2024)
4. (i) Write a C program to perform Matrix Multiplication.(8)
(ii) Write a C programming to Sort the following numbers using selection sort :
45,6,89,3,4,56,10. (8) (NOV/DEC 2024)
5. (i)Compare one dimensional and two dimensional array. Explain the use of multi-
dimensional arrays with syntax and example. (10)
(ii) Explain the four string functions with suitable examples.(6) (APR/MAY 2024)
6. (i) Write an algorithm to sort an array of integers in ascending order using
selection sort and find its time complexity. (10)
(ii) Write a simple binary search program using an iterative method. (6)
(APR/MAY 2024)
7. (i) Write the string handling function used to do the following.(2+2+2+2)
If first name, last name and middle name are given as input, display it as full
name.
Display the number of characters in full name.
Convert the first name into capital letters and last name into small letters.
Print the full name in reverse order.
(ii) In a restaurant, the tables are arranged in a room row-wise order. A waiter is
assigned to serve food for each row. Write a C program to find the highest bill
served by each waiter.(8) (NOV/DEC 2023)
8. (i)Explain binary search technique with an example. How to search for the key
'14' in the array of numbers 12, 56, 90, 14, 19, 63, 88, 25, 37, 49, 110.(3+4)
(ii) In a Marathon, there are 5 tracks. In each track 'n' number of participants are
placed. Find the youngest and oldest participant in each track.(9) (NOV/DEC
2023)
9. (i)What is an array? Explain about one dimensional array with a sample program.
(8)
(ii) Write about the significance of header file, 'string.h' and write short notes on
any three string functions.(8) (APR/MAY 2023)
10. (i) Write and explain the procedure for selection sort.(8)
(ii) Write a C program to demonstrate matrix addition.(8) (APR/MAY 2023)
11. (i)Write a C program to multiply two matrices (2D array) by getting input from
the user.(8)
(ii)Write a C program to find sealing of two matrices (2D array) which will be
entered by a user.(8) (NOV/DEC 2022)
12. (i)Write a C program to find determinant of a matrix (2D array) which will be
entered by a user.(8)
(ii) Write a C program for matrix transpose.(8) (NOV/DEC 2022)
13. (i) What is an array?Explain about various types of arrays in detail. (8)
(ii) Explain the usage of 'streat() with an C program.(8) (APR/MAY 2022)
14. (i) Differentiate binary search from linear search.(8)
(ii) Write a C program to compare two strings without using the function
'stremp()'.(8) (APR/MAY 2022)
UNIT III
Strings & Pointers & Structures & Unions
One-dimensional and Multi-dimensional Arrays, Array operations and traversals, String
Handling: String declaration, input/output, string library functions, Pointer arithmetic,
Pointers and Arrays, Pointers to function, Dynamic memory allocation.
Defining and using structures, Array of structures, Pointers to structures, Unions and their
uses, Enumerations.

PART-A

1. Differentiate constant pointer and pointer to a constant (Apr/May-2025)


a. Constant pointer: The pointer address is fixed, but the value can change.
b. Pointer to a constant: The value pointed to is fixed, but the pointer can
change address.
2. List the MongoDB datatypes with its description? (Apr/May-2025)
Use of array of pointers:
 It is used to store multiple strings efficiently.
 Each pointer can point to a string or dynamically allocated array, allowing flexible
memory usage.
3. Differentiate between structure and union. (Apr/May-2025)

a. Structure: All members have separate memory; can store all members
simultaneously.
b. Union: Members share memory; only one member can hold a value at a time;
saves memory.
4. What is the Output of following program? (NOV/DEC 2024)
# include <stdio.h>
void fun(int *ptr)
*ptr = 30;
}
int m a i n
int y = 20;
fun(&y);
printf("%d", y);
return0;
The output will be 30.
The function modifies the value of y by using a pointer, so y becomes 30 after the call
to fun().
5. List any two math built-in functions. (NOV/DEC 2024)
a. sqrt(): Computes the square root of a number.
b. pow(): Calculates the power of a number.
6. How the pow() function is defined and which header file provides it? (APR/MAY
2024)
The pow() function calculates the power of a number. It is defined in the math.h header file.
Syntax: double pow(double base, double exponent); It returns base raised to the power of
exponent.
7. Differentiate pass by reference and pass by value in C. (APR/MAY 2024)
a. Pass by Value: The function receives a copy of the argument. Changes to the
parameter do not affect the original variable.
b. Pass by Reference: The function receives the address of the argument. Changes
to the parameter affect the original variable directly (using pointers).
8. Find the output of the following code. (NOV/DEC 2023)
int main()
int a = 10, b = 20;
change(&a, b);
printf(" n Inside Main : %d %d\n", a,b);
return 0;
void change(int *p, int q)
*p= =*p*3;
9 = 9*4;
printff"n Inside function : %d %d", *p, q;
}
Inside function: 30 80
9. If p is a pointer to a float array a[10] with base address 1000, then what is the value of
p after executing the statement p++;? Justify your answer. (NOV/DEC 2023)
If p is a pointer to a float array a[10] with a base address of 1000, then after executing p++,
the value of p will increase by the size of the data type it points to, which is float.A float
typically occupies 4 bytes in [Link] p is a pointer to a float, after p++, the pointer
will move to the next float element in the array. Justification:
The base address of a[0] is 1000.
After p++, p will point to a[1], which is located at 1000 + 4 = 1004.
Thus, the value of p after p++ will be 1004.
10. What is the function prototype? Give an example. (APR/MAY 2023)
Answer: A function prototype declares the function's signature (return type, name, and
parameters) before its actual definition.
Example:
int add(int a, int b); // Function prototype
11. What are the difference between user defined functions and built-in functions?
(APR/MAY 2023)
a. User-defined Functions: Functions created by the programmer to perform
specific tasks.
b. Built-in Functions: Predefined functions provided by the C library (e.g., printf(),
scanf()).
12. How is pointer arithmetic done? (NOV/DEC 2022)
Pointer arithmetic is done by adding or subtracting an integer from a pointer, which moves
the pointer by that number of elements, not bytes. Example:
int arr[] = {1, 2, 3};
int *p = arr;
p++; // Now p points to arr[1]
13. Which is better to use? Macro or function. Justify your answer. (NOV/DEC 2022)
Function is generally better to use because it allows type checking, debugging, and easier
maintenance. Macros are processed by the preprocessor and can lead to issues like no type
safety and difficulties in debugging.
14. Define the term recursion in language C. (APR/MAY 2022)
Recursion in C is a process where a function calls itself in order to solve a problem. It is
used for problems that can be broken down into smaller, similar sub-problems.
15. What is the relation between the operators '&' and ' * ' in C pointers? (APR/MAY
2022)
& is the address-of operator used to get the memory address of a variable, while * is
the dereference operator used to access the value at the address pointed to by a pointer.
Example:
int a = 5;
int *p = &a; // & gets address, * accesses value at the address

PART-B

1. (i) Explain in detail about the Built-in math functions with an example.
(ii) Write a program to search a particular number in a set of numbers using
binary search. (Apr/May-2025)
2. (i) Write the C program to find the nᵀʰ term of the Fibonacci series using
recursion
(ii) Write the C program to swap the values of the two variables using pass by
value and pass by reference. (Apr/May-2025)
3. (i) Write a C program to generate fibonacci series using a recursive method.
(ii) Compare pass by value and pass by reference with an example. (NOV/DEC
2024)
4. (i) Write a C program to find if the string is palindrome or not.
(ii) Write a program in C to count the number of vowels and consonants in a
string using a pointer. (NOV/DEC 2024)
5. (i)Write different types of functions with respect to return type arguments and
explain all types with syntax and example,
(ii)Explain the header file that contains various methods for performing
mathematical operations. (APR/MAY 2024)
6. (i)Discuss call by value and call by reference with some simple program.
(ii) What is a recursive function? Write a simple binary search algorithm using
recursive functions (APR/MAY 2024)
7. (i)Write a C program to create two 2D arrays using array of pointers. First 2D
array consists of a list of employee names and the second 2D array consists of
their designation. Your code should display the designation when name is
entered.
(ii) Give an example for a function that receives parameters and returne no
value. (NOV/DEC 2023)
8. (i)Create an array of lucky ticket numbers announced for prize bonanza. Get a
ticket number and check it for prize and display the result. Use pointer to array
concept.
(ii) Differentiate between 'Pass by value' and 'Pass by reference' with an
example. (NOV/DEC 2023)
9. Write short notes on the following:
(i) function prototype and function call
(ii) function definition and return value (APR/MAY 2023)
10. Enumerate the difference between call by value and call by reference with
suitable examples. (APR/MAY 2023)
(i) Classify the function prototypes with suitable examples.
(ii) Write a C program to design the scientific calculator using built-in
functions. (NOV/DEC 2022)
11. (i)Explain the concept of pass by value and pass by reference. Write a C
program to swap the content of two variables using pass by reference.
(ii)Explain about pointers and write the use of pointers in arrays with suitable
example. (NOV/DEC 2022)
12. What is modular Programming? How does the Language C support modular
programming? Explain in detail. (APR/MAY 2022)
13. What is the necessity of parameter passing in C Programs? What are the two
types of doing that? Explain any one in detail. (APR/MAY 2022)

UNIT IV
File Operations & Standard Libraries & Header Files
Open, read, write, close file operations, Binary vs Text files, File pointers, Error handling in
file operations. Using standard libraries like stdio.h, stdlib.h, string.h, math.h, Creating and
using user-defined header files and libraries

PART-A

1. Write the syntax of typedef? (Apr/May-2025)


typedef existing_data_type new_name;
Example:
typedef unsigned int uint;
uint a = 10;
2. List the different modes of opening a file. (Apr/May-2025)

a. "r" – read, "w" – write, "a" – append


b. "r+" – read/write, "w+" – read/write with overwrite, "a+" – read/append
3. Write the use of fseek() functions (Apr/May-2025)

a. fseek() moves the file pointer to a specific location in a file.


b. Useful for random access, skipping data, or appending.
4. Differentiate between Sequential and random access. (NOV/DEC 2024)
a. Sequential Access: Data is accessed in a sequence, one after another (e.g., tapes).
b. Random Access: Data can be accessed directly at any position without a sequence
(e.g., hard drives, arrays).
5. Write the functions of fscanf and fprintf. (NOV/DEC 2024)
a. fscanf: Reads formatted input from a file.
fscanf(file, "%d", &x);
b. fprintf: Writes formatted output to a file.
fprintf(file, "%d", x);
6. What is the typedef function in C? (APR/MAY 2024)
typedef is used to define a new name (alias) for an existing data type. It simplifies complex
data type definitions.
Example:
typedef unsigned int uint;
7. List the properties of Command-Line arguments in C. (APR/MAY 2024)
argc: An integer representing the number of command-line arguments.
argv[]: An array of strings representing the arguments passed to the program. argv[0] is the
program name, and the rest are the arguments.
8. What will be the values for arge and argy I when the input "run with my values" is
passed as command line arguments? (NOV/DEC 2023)
When the input "run with my values" is passed as command line arguments, the values for
argc and argv[] will be:
a. argc (argument count) will be 5, as there are 5 words (including the program name
itself).
b. argv[] (argument vector) will be:
c. argv[0] = "run" (program name)
d. argv[1] = "with"
e. argv[2] = "my"
f. argv[3] = "values"
9. Name any two functions used in Random access files and specify their use in C
programming. short two mark answer(NOV/DEC 2023)
a. fseek():
Purpose: Used to move the file pointer to a specific location in the file.
Syntax: int fseek(FILE *stream, long offset, int whence);
b. ftell():
Purpose: Used to get the current position of the file pointer.
Syntax: long ftell(FILE *stream);
Both functions are used in random access file operations to read or write data at specific
positions within the file.
10. Describe the prototype of the function fopen. (APR/MAY 2023)
Answer: The fopen function is used to open a file and returns a file pointer.
Prototype:
FILE *fopen(const char *filename, const char *mode);
11. List the various modes of accessing a file through C. (APR/MAY 2023)
The various modes for file operations are:
"r": Read (opens file for reading).
"w": Write (creates or truncates the file for writing).
"a": Append (opens file for appending).
"rb", "wb", "ab": Binary modes for reading, writing, and appending.
"r+", "w+", "a+": Read and write modes.
12. Why are files needed? (NOV/DEC 2022)
Files are used to store data permanently or for future retrieval. They allow programs to
read, write, and manipulate data even after the program execution has ended.
13. Give an example for fseek()(NOV/DEC 2022)
FILE *fp = fopen("[Link]", "r");
fseek(fp, 10, SEEK_SET); // Moves the file pointer 10 bytes from the beginning
14. What will be the impact if 'close() function is avoided in a file handling C program?
(APR/MAY 2022)
If close() is not called, the file may not be properly saved or closed, leading to data loss,
memory leakage, or file corruption. It also keeps the file open, consuming system
resources.
15. What are command line arguments? (APR/MAY 2022)
Command line arguments are inputs provided to a program when it is executed from the
command line. They can be accessed in C via argc (argument count) and argv[] (argument
vector). Example:
int main(int argc, char *argv[]) {
// argc and argv are used to access command-line arguments
}

PART-B

1. A record contains information regarding book store such as book name, bookid,
price, author, publication details. Create a file to hold the records of N books. Write a
C program (Apr/May-2025)

2. (i) To insert new book details into book stores


(ii) Read all books in file and print available in the book store according to bookid.
(Apr/May-2025)

3. Write a C program to copy content of one file to another file. (NOV/DEC 2024)
4. List the various types of file processing and explain any two. (NOV/DEC 2024)
5. What is File Organization? Explain its types with pros and cons. (APR/MAY 2024)
6. (i)What is a File and list any five operations that can be performed on a
file. (APR/MAY 2024)
(ii)What are command line arguments in C? Explain with a suitable program.
7. (i)Mention the purpose of fseek() function in random files.
(ii) When to use fread() and fwrite() functions in file processing?
(iii) List down the modes in which a C file can be opened. Specify the purpose of
each mode.
(iv) What is the use of feof() function?(3) (NOV/DEC 2023)
8. Write a C program to create a binary file in C named "application. txt" that has the
data such as citizen name, aadhar number, pan number, employment, gender and
age. Filter the application by analyzing the gender and employment and move all the
male applicants who are self-employed into another file called "[Link]". Assume
minimum 10 candidates. (NOV/DEC 2023)
9. How does random accessing of files are done in C language? Explain in
detail. (APR/MAY 2023)
10. [Link] is the purpose of the variables arge and argy of command line arguments in
C language? Explain with a sample program. (APR/MAY 2023)
11. Write a C program to get name and marks of 'n' number of studerite from user and
store them in a file.

(ii)Write a C program to read name and marks of 'n' number of students from user
and store them in a file. If the file previously exits then append the information into
the existing file. (NOV/DEC 2022)

12. Write a C program to write all the members of an array of structures to a file using
fwrite. Read the array from the file and display on the screen.
(ії)Describe command line arguments with example C program. (NOV/DEC 2022)
13. What is file? What are facilities available in language C to handle files?
Explain. (APR/MAY 2022)
14. Explain the various file accessing policies available in language C with appropriate
programs. (APR/MAY 2022)

You might also like