0% found this document useful (0 votes)
48 views

CS3251 Programming in C 2 Marks

Uploaded by

karthiga.mecse
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

CS3251 Programming in C 2 Marks

Uploaded by

karthiga.mecse
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

CS3251 PROGRAMMING IN C

2 MARKS WITH ANSWERS


Class: I/II SEM

UNIT I BASICS OF C PROGRAMMING


Introduction to programming paradigms - Structure of C program - C programming: Data Types –
Storage classes - Constants – Enumeration Constants - Keywords – Operators: Precedence and
Associatively - Expressions - Input/output statements, Assignment statements – Decision making
statements - Switch statement – Looping statements – Pre- processor directives - Compilation
process

PART A

1. Define programming paradigm.


Programming paradigm is a style or way of programming. The are
procedural, functional, object-oriented, logic programming.
Some of the programming languages are
 Fortran
 Cobol
 Basic
 Pascal
 C

2. Give two examples for assignment statements.


Syntax for assignment : variable = expression / value ; Example :
x=100;
y= a+b;

3. Distinguish between character and string.

No. Character String


i. It is a single character. It is a sequence of characters.
ii. It is enclosed by single quotes. It is enclosed by double quotes.
iii. Example : ‘C’ Example : “Computer”

1
4. What are keywords? Give an example
 Keywords are reserved words, they have standard and predefined meaning.
 Keywords cannot be used as normal identifiers.
 Example : auto, break, char, continue, else, if, switch, struct, union.
5. What do you mean by variables in ‘C’ ?
A variable is an identifier that is used to represent some specified type of information.
Syntax : data_type variable_name;
Example : int marks;

6. Identify the use of ternary or conditional operator.


 ?: is known as conditional operator.It evaluates the first expression if the
condition is true otherwise the second expression is evaluated.
 Syntax : condition ? exp1 : exp2 ;

7. What is mean by Operators precedence and associativity ?


 The precedence is used to determine how an expression involving more than
one operator is evaluated.
 The operator at higher level of precedence is evaluated first. The
evaluation is based on PEMDAS rule.
 The operator of same precedence evaluated from either from left to right or
right to left depending on level is known as associativity.

8. What is a compilation process?


Compiler converts source code into executable code. It includes
 Pre-processor
 Compilation
 Assembly
 Linking

9. How to create enumeration constants ?


 Enumerated data type is a user defined data type. Enumerated data type helps
in creating a list of identifiers also called as symbolic numeric constants of
type int.
 enum keyword is used to create enumeration constant.

Syntax : enum identifier{value1, value2,…….,value n}; Example :

enum holidays{sun, sat};

2
10. Differentiate between an expression and a statement in C.

No. Expression Statements


i. Expression consists of It is defined as a set of declaration or
operators and operands. sequence of actions.
ii. Example: a=29; Example: Assignment statement
b=a+77; Mark=73;

11. What is the output of the programs given below?


#include <stdio.h>
main( )
{
int a = 20, b = 10, c = 15, d = 5; int
e;
e = (a + b) * c / d;
printf("Value of (a + b) * c / d is : %d\n", e );
}

OUTPUT :

Value of (a + b) * c / d is : 90

12. Generalize the types of I/O statements available in ‘C’.


Unformatted Input / Output statements
 Input : getc(), getchar(), gets(), getche(), getch()
 Output : putc(), putchar(), puts().
Unformatted Input / Output statements
 Input : scanf(), fscanf()
 Output : printf(), fprintf()

13. Classify the different types of storage classes .


There are mainly four types of storage classes. They are
 Automatic (auto)
 Static
 External (extern)
 Register

3
14. Discover the meaning of C pre-processor
1. The preprocessor contains any operations in the processing language, it will be
transformed first.
2. The preprocessing language consists of
 Inclusion of header file
 Macro expansion
 Conditional compilation
 Line control
 Diagnostics

15. Invent the difference between ++a and a++.


 ++a is known as pre increment where the value is incremented by one and then the
operation is done.
 a++ is known as post increment where the operation is done first and then the
value is incremented by one.

4
UNIT II ARRAYS AND STRINGS
Introduction to Arrays: Declaration, Initialization – One dimensional array – Example Program:
Computing Mean, Median and Mode - Two dimensional arrays – Example Program: Matrix
Operations (Addition, Scaling, Determinant and Transpose) - String operations: length, compare,
concatenate, copy – Selection sort, linear and binary search.

PART A

1. List out the features of Arrays.


 An array is used to represent a collection of elements of same data type.
 The elements in an array can be accessed by usin the base address.
 The elements are stored in continuous memory locations,The starting memory
location is known as the array name and it is known as the base address ( index ) of
the array.

2. Define a float array of size 5 and assign 5 values to it.
main( )
{
float a[5] = {26.9, 32.4, 84.2, 20.0, 78.1};
}

3. Identify the main elements of an array declaration.


 Arrays are declared like variable declaration but the array declaration has size of the
array.

Syntax : data_type array_name[size]; [OR]


data_type array_name[array_size]={list_of_values};

Example for array declaration : int marks[6];

4. Point out an example code to express two dimensional array.


 A two dimensional array is created by specifying its row and column size.

Examples : int matrix[2][2];


int a[3][2];

5
5. How to create a two dimensional array?
Two dimensional arrays are stored in a row-column matrix, where the left index
indicates the row and right matrix indicates the column.

Syntax : data_type array_name[row_size][column_size]; Example

: int mat[3][3];

6. What are the different ways of initializing array?


 Values can be assigned to an array by normal declaration otherwise they hold
garbage values.
 Arrays can be initialized in following two ways :
i. At compile time
ii. At Run time

7. What is the use of ‘\0’ and ‘%s’?


 ‘\0’ is the escape sequence for null character it is automatically added at the end of
the string.
 ‘%s’ is a format specifier for string. It is used in scanf( ) and printf( ) functions
to get the string input or to print string output.

8. What is the role of strrev( )?


The function strrev( ) is used to reverse a string. This function takes only one argument and
return only one argument.

Syntax : strrev(string_to_be_reversed);

9. Define string.
 String is a sequence / array of characters enclosed with double quotes.
 Null character (‘\0’) is used to mark the end of the string

C O M P U T E R \0

Example : char word= “computer”;

10. Name any two library functions used for string handling.
 strlen() – finds the length of a string. It returns an integer value. It counts the number
of characters except null character and returns the count Syntax : strlen(str)

6
 strcpy() – copies the source string into destination string. So, the source string
should be enough to store the destination string.
Syntax : strcpy(source,destination)

11. Define sorting.


 Sorting is a process of arranging the elements either in ascending order or descending
order.
 Sorting refers to ordering data in an increasing or decreasing fashion according
to some linear relationship among the data items.
 Sorting can be done on names, numbers and records.

12. Define Multi-dimensional array.


 Multi-dimensioned arrays have two or more index values which specify the
element in the array.

Declaration:
int m1[10][10];
static int m2[2][2] = { {0,1}, {2,3} };

13.Given an array int a[10]={101,012,103,104,105,106,107,108,109,110}.


Show the memory representation and calculate its length. Memory

Representation:

101 102 103 104 105 106 107 108 109 110
a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9]
Length calculation:
Length of an array=upper_bound - lower_bound + 1 Here,
upper_bound = 9 and lower_bound = 0
Thus, length of an array = 9-0+1 = 10

14. What are the types of sorting available in C?


 Insertion sort.
 Merge Sort.
 Quick Sort.
 Radix Sort.
 Heap Sort
 Selection sort
 Bubble sort

7
15. What is the difference between an array and pointer?

No. Array Pointer


i. Array allocates space Pointer is explicitly assigned to
automatically. point to an allocated space

ii. It cannot be resized It can be resized using realloc ()


iii. It cannot be reassigned Pointers can be reassigned.

iv. Size of(array name) gives the Sizeof(pointer name) returns the
number of bytes occupied by the number of bytes used to store the
array. pointer variable.

16. Mention the various String Manipulation Functions in C.


strcpy(s1, s2); Copies string s2 into string s1.
strcat(s1, s2); Concatenates string s2 onto the end of string s1.
strlen(s1); Returns the length of string s1.
strcmp(s1, s2); Returns 0 if s1 and s2 are the same; less than 0 if s1<s2; greater
than 0 if s1>s2.
strchr(s1, ch); Returns a pointer to the first occurrence of character ch in string
s1.
strstr(s1, s2); Returns a pointer to the first occurrence of string s2 in string s1.

17. What is the use of atoi() function?


 C allows us to manipulate characters the same way we do with numbers. Whenever a
character constant or character variable is used in an expression, it is automatically
converted into integer value by the system.
 For eg, if the machine uses the ASCII representation, then,
x = ‘a’; printf(“%d \n”,x);
will display the number 97 on the screen.
 The C library supports a function that converts a string of digits into their integer
values.

18. Define Searching


 Searching is a process of finding the position of a given element in a list.
 The searching is successful if the element is found. There are two types of searching.
 Linear Search
 Binary Search

8
UNIT III FUNCTIONS AND POINTERS
Introduction to functions: Function prototype, function definition, function call, Built‐in functions
(string functions, math functions) Recursion – Example Program: Computation of Sine series,
Scientific calculator using built‐in functions, Binary Search using recursive functions – Pointers
– Pointer operators – Pointer arithmetic – Arrays and pointers – Array of pointers – Example
Program: Sorting of names – Parameter passing: Pass by value, Pass by reference –
ExampleProgram: Swapping of two numbers and changing the value of a variable using pass by
reference.

PART A

1. What is a function?
 Function is a set of instructions
 Self contained block
 Performs a specific task
 Used to avoid redundancy of code
2. What is the need for functions?
 To reduce the complexity of large programs
 To increase the readability
 To achieve reusability
 To avoid redundancy of code
 To save Memory
3. What are the uses of pointer?
 Saves Memory Space
 Used for dynamic memory allocation
 Faster execution
 Used to pass array of values to a function as a single argument
4. Define typedef .
 The typedef keyword enables the programmer to create a new data type name by
using an existing data type.
 By using typedef, no new data is created, rather an alternate name is given to a
known data type.

Syntax: typedef existing_data_type new_data_type;

5. What is an Address operator & Indirection operator?


 Address operator: & -used to assign the address to a pointer variable,
Referencing operator

9
 Indirection operator : *- Dereferencing operator is used to access the value at
the pointer variable
Ex: int a=5; int
*p=&a;
printf(“%d”,*(p));

6. Compare actual parameter & formal argument


Actual argument: Specified in the function call statement. Used to supply the
input values to the function either by copy or reference
Formal argument: Specified in the function definition statement. It takes either copy
or address of the actual arguments

7. How is pointer arithmetic done?


Pointer Arithmetic:
Valid operation

 Pointer can be added with a constant


 Pointer can be subtracted with a Constant
 Pointer can be Incremented or Decremented Not
Valid
 Two pointers can not be added,subtracted,multiplied or divided
Ex: int a=10
int *p=&a; p
2000 10 a
p=p+1;
2002
 The pointer holds the address 2000. This value is added with 1.
 The data type size of the constant is added with the address. p=
2000+(2*1)=2002
8. List out any 4 math functions
pow(x,y) : used to find power of value of xy .Returns a double value log10(x)
: used to find natural logarithmic value of x
sqrt(x) : used to find square root vale of x
sin(x) : returns sin value of x

10
9. What is a function prototype?
 Function prototype is a function declaration statement.
Syntax : return_type function_name( parameters_list) Example:
int factorial(int);

10. Differentiate call by value and call by reference.


Call by value: The values of the variables are passed by the calling function to the called
function.
Call by reference: The addresses of the variables are passed by the calling function to
the called function.

11. List the header files in ‘C’ language.


 <stdio.h> contains standard I/O functions
 <ctype.h> contains character handling functions
 <stdlib.h> contains general utility functions
 <string.h> contains string manipulation functions
 <math.h> contains mathematical functions
 <time.h> contains time manipulation functions

12. What are the steps in writing a function in a program?


Function Declaration (Prototype declaration):
 Every user-defined functions has to be declared before the main().
Function Callings:
 The user-defined functions can be called inside any functions like main(),
userdefined function, etc.
Function Definition:
 The function definition block is used to define the user-defined functions
with statements.

13. State the advantages of user defined functions over pre-defined function.
 A user defined function allows the programmer to define the exact function of the
module as per requirement. This may not be the case with predefined function. It
may or may not serve the desired purpose completely.
 A user defined function gives flexibility to the programmer to use optimal
programming instructions, which is not possible in predefined function.

11
14. Write the syntax for pointers to structure.
Struct S
{
char datatype1;
int datatype2;
float datatype3;
};
Struct S *sptr //sptr ia pointer to structure S

15. Write the advantages and disadvantages of recursion.


Recursion makes program elegant and cleaner. All algorithms can be defined recursively
which makes it easier to visualize and prove.
If the speed of the program is vital then, you should avoid using recursion.
Recursions use
more memory and are generally slow. Instead, you can use loop.

16. What is meant by Recursive function?


 If a function calls itself again and again, then that function is called Recursive
function.

Example:
void recursion()
{
recursion(); /* function calls itself */
}
int main()
{
recursion();
}

17. Is it better to use a macro or a function?


 Macros are more efficient (and faster) than function, because their corresponding
code is inserted directly at the point where the macro is called.
 There is no overhead involved in using a macro like there is in placing a call to a
function. However, macros are generally small and cannot handle large, complex
coding constructs.
 In cases where large, complex constructs are to handled, functions are more suited,
additionally; macros are expanded inline, which means that the code is replicated
for each occurrence of a macro.

12
UNIT IV STRUCTURES

Structure ‐ Nested structures – Pointer and Structures – Array of structures – Example


Program usingstructures and pointers – Self referential structures – Dynamic memory
allocation ‐ Singly linked list
‐typedef

PART A

1. Compare arrays and structures.

Arrays Structures
An array is a collection of data items of A structure is a collection of data items of different
same data type. Arrays can only be data types. Structures can be declared and defined.
declared.

There is no keyword for arrays. The keyword for structures is struct.

An array cannot have bit fields. A structure may contain bit fields.

An array name represents the A structure name is known as tag. It is a


address of the starting element. Shorthand notation of the declaration.

2. Difference between structure and union.

Structure Union

Every member has its own memory. All members use the same memory.

The keyword used is struct. The keyword used is union.

All members occupy separate memory


location, hence different interpretations of Different interpretations for the same
the same memory location are not memory location are possible.
possible. Consumes more space compared Conservation of memory is possible
to union.

13
3. Define Structure in C
C Structure is a collection of different data types which are grouped together and each
element in a C structure is called member.
If you want to access structure members in C, structure variable should be declared.
Many structure variables can be declared for same structure and memory will be
allocated for each separately.
It is a best practice to initialize a structure to null while declaring, if we don’t assign any
values to structure members.

4. What you meant by structure definition?


A structure type is usually defined near to the start of a file using a typedef statement.
typedef defines and names a new type, allowing its use throughout the program.
Typedefs usually occur just after the #define and #include statements in a file.
Here is an example structure definition.
typedef struct { char
name[64];
char course[128];
int age;
int year;
} student;
This defines a new type student variables of type student can be declared as follows.
student st_rec;

5. How to Declare a members in Structure?


A struct in C programming language is a structured (record) type[1] that aggregates a
fixed set of labeled objects, possibly of different types, into a single object. The
syntax for a struct declaration in C is:
syntax :
struct tag_name
{
type
attribute;
type
attribute2;
/* ... */
};

14
6. What is meant by Union in C?
A union is a special data type available in C that enables you to store different data
types in the same memory location. You can define a union with many members, but
only one member can contain a value at any given time.
Unions provide an efficient way of using the same memory location for multi-
purpose.

7. How to define a union in C.


To define a union, you must use the union statement in very similar was as you did while
defining structure. The union statement defines a new data type, with more than one
member for your program. The format of the union statement is as follows:
union [union tag]
{
member
definition;
member
definition;
...
member definition;
} [one or more union variables];

8. What are storage classes?


A storage class defines the scope (visibility) and life time of variables and/or functions
within a C Program.

9. What are the storage classes available in C?


There are following storage classes which can be used in a C Program
1. auto
2. register
3. static
4. Extern

10. What is register storage in storage class?


Register is used to define local variables that should be stored in a register instead of
RAM.
This means that the variable has a maximum size equal to the register size (usually
one word) and cant have the unary '&' operator applied to it (as it does not have a
memory location).

15
11. What is static storage class?
Static is the default storage class for global variables. The two variables below
(count
and road) both have a static storage class. static
int Count; int Road;
{
printf("%d\n", Road);
}

12. Define Auto storage class in C.


auto is the default storage class for all local variables.
{
int Count;
auto int
Month;
}
The example above defines two variables with the same storage class. auto can only be
used
within functions, i.e. localariables.

13. Define Macro in C.


A macro definition is independent of block structure, and is in effect from the
#define directive that defines it until either a corresponding #undef directive or the end of
the compilation unit is encountered.
Its format is: #define identifier replacement
Example:
#define
TABLE_SIZE 100
int table1[TABLE_SIZ
E]; int
table2[TABLE_SIZ
E];
14. What is Line control?
Line control (#line)
When we compile a program and some error happens during the compiling process, the
compiler shows an error message with references to the name of the file where the error
happened and a line number, so it is easier to find th

16
UNIT V FILE PROCESSING
Files – Types of file processing: Sequential access, Random access – Sequential access file
‐ Example Program: Finding average of numbers stored in sequential access file ‐
Random access file ‐ Example Program: Transaction processing using random access files
– Command line arguments

PART A

1. Why files are needed?


When a program is terminated, the entire data is lost. Storing in a file will preserve your
data even if the program terminates.

2. What are the types of Files ?


When dealing with files, there are two types of files you should know about:
1. Text files
2. Binary files
Text files
Text files are the normal .txt files that you can easily create using Notepad
or any simple text editors.
When you open those files, you'll see all the contents within the file as plain text.
You can easily edit or delete the contents.
They take minimum effort to maintain, are easily readable, and provide least
security and takes bigger storage space.
Binary files
Binary files are mostly the .bin files in your computer.
Instead of storing data in plain text, they store it in the binary form (0's and 1's).
They can hold higher amount of data, are not readable easily and provides a better
security than text files.

3. Enlist the File Operations.


In C, you can perform four major operations on the file, either text or binary:
1. Creating a new file
2. Opening an existing file
3. Closing a file
4. Reading from and writing information to a file

17
Working with files
When working with files, you need to declare a pointer of type file. This declaration is
needed for communication between the file and program. FILE *fptr;
4. How to open a file?
Opening a file is performed using the library function in the "stdio.h"
header file: fopen().
The syntax for opening a file in standard I/O is: ptr =
fopen("fileopen","mode")

5. How to close a file?


The file (both text and binary) should be closed after reading/writing. Closing a
file is performed using library function fclose(). fclose(fptr); //fptr is the file
pointer associated with file to be closed.

6. Reading and writing to a text file


For reading and writing to a text file, we use the functions fprintf() and fscanf().
They are just the file versions of printf() and scanf(). The only difference is that,
fprint and
fscanf expects a pointer to the structure FILE.

7. What are two main ways a file can be organized?


1. Sequential Access — The data are placed in the file in a sequence like beads on a
string. Data are processed in sequence, one after another. To reach a particular item
of data, all the data that proceeds it first must be read.
2. Random Access — The data are placed into the file by going directly to the
location in the file assigned to each data item. Data are processed in any order.
A particular item of data can be reached by going directly to it, without looking at
any other data.
8. What is file?
A file is a semi-permanent, named collection of data. A File is usually stored on
magnetic media, such as a hard disk or magnetic tape.
Semi-permanent means that data saved in files stays safe until it is deleted or
modified.
Named means that a particular collection of data on a disk has a name, like
mydata.dat and access to the collection is done by using its name.

9. State Report Generation.


A very common data processing operation is report generation. This is when the
data in a file (or files) is processed by a program to generate a report of some kind.
The report might be a summary of the financial state of a corporation, or a series of
bills for its customers, or a series of checks to be mailed to its employees.
Large corporations have very large databases kept on many high capacity disks and
processed by programs running on large computers called mainframe

10. State Transaction Processing.


As data flows into an organization, the files that keep track of the data must be
updated. For example, data flows into a bank from other banks and ATM machines.

18
Often this data is gathered as it occurs into a transaction file. Periodically (often
overnight) the data in the transaction file is used to update the main file of data.
The picture shows the main file and the transaction file as input to a program. The
output is a new, updated main file. The previous version of the file can be kept as
backup. Management information science is the field that studies how to organize
and manage the information of a corporation using computers and files. Usually the
business school of a university has a management information science department.

11. List the Types of Files.


There are two main ways a file can be organized:
1. Sequential Access — The data are placed in the file in a sequence like beads on a
string. Data are processed in sequence, one after another. To reach a particular item
of data, all the data that proceeds it first must be read.
2. Random Access — The data are placed into the file by going directly to the
location in the file assigned to each data item. Data are processed in any order. A
particular item of data can be reached by going directly to it,
without looking at any other data.

12. What is command line arguments?


It is possible to pass some values from the command line to your C programs when
they are executed. These values are called command line arguments and many times
they are important for your program especially when you want to control your
program from outside instead of hard coding those values inside the code.
The command line arguments are handled using main() function arguments
where argc refers to the number of arguments passed, and argv[] is a pointer
array which points to each argument passed to the program.

13. Write an example program for command line arguments.


#include <stdio.h>
int main( int argc, char *argv[] )
{
if( argc == 2 ) {
printf("The argument supplied is %s\n", argv[1]);
}
else if( argc > 2 )
{
printf("Too many arguments supplied.\n");
}
else
{
printf("One argument expected.\n");
}}

19
14. Write the functions for random access file processing.
1. fseek()
2. ftell()
3. rewind()

15. Write short notes on fseek().


fseek():
This function is used for seeking the pointer position in the file at the specified
byte.
Syntax: fseek( file pointer, displacement, pointer position);
Where
file pointer--------It is the pointer which points to the file.
displacement---------It is positive or negative.This is the number of bytes

which are skipped backward (if negative) or forward( if positive) from the current
position.This is attached with L because this is a long integer.

Pointer position:
This sets the pointer position in the file.

Value pointer position

0 Beginning 0

1 Current position

2 End of file

16. Give an example for fseek().


1) fseek( p,10L,0)
0 means pointer position is on beginning of the file,from this statement pointer
position is skipped 10 bytes from the beginning of the file.
2) fseek( p,5L,1)
1 means current position of the pointer position.From this statement pointer
position is skipped 5 bytes forward from the current position.
3) fseek(p,-5L,1)
From this statement pointer position is skipped 5 bytes backward from the current
position.

20
PART B IMPORTANT QUESTIONS

UNIT I
BASICS OF C PROGRAMMING

1. Describe the structure of a C Program.


2. List the different data types available in C.
3. What are constants? Explain the various types of constants in C.
4. Explain the different types of operators available in C.
5. Describe the various looping statements used in C with suitable examples.
6. Explain about various decision making statements available in C with illustrative
programs.
7. Write the operations of compilation process.
8. Write a C program to print the Fibonacci series of a given number.
9. Write a C program to solve the quadratic equation and to find a Factorial of a given
number.
10. Write a C program to check whether a given number is prime number or not.

UNIT II
ARRAYS AND STRINGS
1. What is an array? Discuss how to initialize a one dimensional and two
dimensional arrays with suitable example?
2. Write a C program to search an element in a given array using linear and binary
search.
3. Write a C program for sorting an array of numbers using selection sort.
4. Write a C program to addition, subtract and multiply two matrices.
5. Write a C program to scaling transformations of a matrix.
6. Write a C program to determinant a matrix.
7. Write a C program to transpose a matrix.
8. Write a C program to find mean, median and mode.
9. Explain in detail about string and list the various string operations with example.
10. Write a C program to find out the length and reverse of the string without using
builtin function

21
UNIT III

FUNCTIONS AND POINTERS

1. What is a function in C? Explain the steps in writing a function in C program with


Example.
2. Classify the function prototypes with example C program for each.
3. What is recursion? Write a C program to find the sum of the digits, to find the
factorial of a number and binary search using recursion.
4. Write a C program to design the scientific calculator using built-in functions.
5. Explain about pointers and write the use of pointers in arrays with suitable example.
6. 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.
UNIT IV
STRUCTURES

1. What is a structure? Create a structure with data members of various types and declare
two structure variables. Write a program to read data into these and print the same.
Justify the need for structured data type.
2. Write a C program to store the employee information using structure and search a
particular employee using Employee number.
3. Define and declare a nested structure to store date, which including day, month and
year.
4. Define a structure called student that would contain name, regno and marks of five
subjects and percentage. Write a C program to read the details of name, regno and marks
of five subjects for 30 students and calculate the percentage and display the name, regno,
marks of 30 subjects and percentage of each student.
5. Explain about array of structures and pointers in structures with example program
6. Write a C program to create mark sheet for students using self referential structure.
7. Discuss about dynamic memory allocation with suitable example C program.
8. Explain about singly linked list with suitable example C program.

22
UNIT V
FILE PROCESSING

1. Explain about files and with it types of file processing.


2. Compare sequential access and random access.
3. Write a C program to finding average of numbers stored in sequential access file and
random access file.
4. Write a C program for transaction processing using random access files.
5. Describe command line arguments with example C program.
6. Write a C Program to calculate factorial and to generate Fibonacci series by using
command line arguments.

23

You might also like