Overall C Question Bank For Students
Overall C Question Bank For Students
Part-A
1. C language is -----------
a)high level b)low level c)middle level d)assembly level
2 .Identifier consist of
a)letter b)keyword c)constant d)function
3. The size occupied by short int is
a)2 b)4 c)3 d)1
4. The format specifier for float is
a)%f b)%ld c)%u d)%c
5. a,b,c are the integer variables , whose values are 1,2,3. What is the return value of the
expression (a+b)>=c
a)0 b)1 c)3 d)2
6. main()
{printf(“a++ = %d”,a++);} what is the output of the program?
a)0 b)11 c)12 d)10
7. Evaluate the expression 9-12/3+3*2-1.
1
14. Which of the following is a string constant?
a)’5’ b)”hello” c)25 d)”6
Part-B
1. What is an identifier?
Identifier are names given to various program elements such as variables , functions and
arrays.
Certain reserved words are called keywords, that have standard and predefined meaning
which cannot be changed. Example: auto, break, case, else, if , int etc.
The value of the variable, whose values cannot be changed during the execution of the
program are called constants.
scanf(“control string”,&arg1,&arg2,…&argn);
Here the control string specifies the field format and &arg1, &arg2 specifies the address of the
variable.
It is a compile time operator and when used with an operand, it returns the number of
bytes occupied by the operand.
The goto statement can cause program control almost anywhere in program
unconditionally, it require a label to identify the place to move the execution.
3 Syntax: Syntax:
break; continue;
It is the multi way decision statement, allows to make decision from number of choices,
if match is found the block of statements associated with it is executed.
3
11. Write the syntax of if else statement.
if(test expression)
{ true block}
else
{ false block}
Statement-x;
#include<stdio.h>
main()
{ int a,b,c;
printff(“enter a b and c”);
scanf(“%d%d%d”,&a,&b,&c);
if(a>b)
{ if(a>c) printf(“%d”,a);
else printf(“%d”,c);}
else { if(c>b)
printf(“%d”,c);
else printf(“%d”,b);}}
13. Write a c program to print the given two numbers is equal or not.
#include<stdio.h>
main ()
{ int a, b;
printf(“enter two numbers”);
scanf(“%d%d”,&a,&b);
if(a==b)
printf(“a and b are equal”);
else printf(“a and b are not equal”); }
switch (expression)
{ case constant 1:
Block1; break;
case constant 2:
Block2; break;
4
.
.
default: break; }
5
18. What do you mean by conditional operator? Give syntax.
Conditional operator is used to check the condition without using if statement. The
syntax is condition ? expression 1 : expression 2;
If the condition is true expression1 is executed otherwise expression2 is evaluated.
Part-C
7. Differentiate the formatted and unformatted Input / Output function present in C Language
and also explain with an example
6
8. Explain about various looping statements in C. Explain with syntax and example.
9. a. Write a program to reverse a given number.
b. Write a program to print prime numbers from 1 to 100.
10. Write a program to solve the following quadratic equation Ax 2 + Bx + C = 0.
11. Write a program to read a list of n elements and find the maximum and minimum without
using array.
12. a. Write a program to find whether the given number is palindrome or not.
b. Write a program to print the Fibonacci series up to 100.
13. Write a program to evaluate the following series
x - x 3 / 3! + x 5 / 5! - x 7 / 7! + ……….
14. Write a program to calculate the sum of remainders obtained by dividing with modular
division operation by 2 on 1 to 9 numbers.
15. How does switch statement differ from if statement? Explain with example.
16. Write a C program to convert the number of years represented by an integer into the
following units of time: a. Minutes, b. Hours, c. Days, d. Months, e. seconds
Use switch() statement.
17. Describe the various operators present in C Language.
18. Explain in detail about the operator precedence and there associatively.
19. Discuss in detail about conditional statement present in C Language with a suitable
example.
20. Create a C- Program which finds the greatest of three numbers using “if” statement.
21. Write a C- Program which finds the greatest of three numbers using the “conditional
operator”.
22. Write a C Program for finding the grade of students with a “switch case”.
23. Write a C Program to find the sum of n numbers using “while” or “do-while”.
24. Create a C Program to print the multiplication table of specified size using “for” statement.
25. Write a C Program to find the Armstrong number.
26. Write a C Program to find the Palindrome number.
27. Write a C Program to find the Factorial of a given number.
28. Write a C Program to find the number of digits in a given number.
Answers: Part-A
1. a 2.a 3.d 4.a 5.b 6.d 7.c 8.b 9.c 10.a 11.b 12.b 13.c 14.b 15.a 16.b 17.b
18.a 19.d 20.c 21.a 22.c
Part-A
1. What will happen if in a C program you assign a value to an array element whose subscript
exceeds the size of array?
7
C. The program may crash if some important data gets overwritten.
4. The keyword used to transfer control from a function back to the calling function is
A. switch B. goto
C. go back D. return
#include<stdio.h>
int main()
{
printf("C program");
main();
return 0;
}
8
C. 65535 times D. Till stack overflows
#include<stdio.h>
int main()
{
int fun();
int i;
i = fun();
printf("%d\n", i);
return 0;
}
int fun()
{
_AX = 1990;
}
C. 1990 D. No output
#include<stdio.h>
int reverse(int);
int main()
{
int no=5;
reverse(no);
return 0;
}
int reverse(int no)
{
if(no == 0)
return 0;
else
printf("%d,", no);
reverse (no--);
}
A. Print 5, 4, 3, 2, 1 B. Print 1, 2, 3, 4, 5
9
C. Print 5, 4, 3, 2, 1, 0 D. Infinite loop
A. -1 B. 1
C. 0 D. Yes
C. printf('\n'); D. printf("\\n");
10. The library function used to find the last occurrence of a character in a string is
A. strnstr() B. laststr()
C. strrchr() D. strstr()
11. Which of the following function is used to find the first occurrence of a given string in another string?
A. strchr() B. strrchr()
C. strstr() D. strnset()
12. Which of the following function is more appropriate for reading in a multi-word string?
A. printf(); B. scanf();
C. gets(); D. puts();
#include<stdio.h>
int main()
{
int fun(int);
int i = fun(10);
printf("%d\n", --i);
return 0;
}
int fun(int i)
10
{
return (i++);
}
A. 9 B. 10
C. 11 D. 8
#include<stdio.h>
int main()
{
int i=1;
if(!i)
printf("IndiaBIX,");
else
{
i=0;
printf("C-Program");
main();
}
return 0;
}
#include<stdio.h>
#include<string.h>
int main()
{
printf("%d\n", strlen("123456"));
return 0;
11
}
A. 6 B. 12
C. 7 D. 2
#include<stdio.h>
int main()
{
printf(5+"Good Morning\n");
return 0;
}
C. M D. Morning
17. What will be the output of the program if the array begins at address 65486?
#include<stdio.h>
int main()
{
int arr[] = {12, 14, 15, 23, 45};
printf("%u, %u\n", arr, &arr);
return 0;
}
18. What will be the output of the program if the array begins 1200 in memory?
#include<stdio.h>
int main()
{
int arr[]={2, 3, 4, 1, 6};
printf("%u, %u, %u\n", arr, &arr[0], &arr);
return 0;
}
12
C. 1200, 1204, 1208 D. 1200, 1202, 1200
20. What will be the output of the program if the array begins at 65472 and each integer occupies
2 bytes?
#include<stdio.h>
int main()
return 0; }
21. If a Storage class is not mentioned in the declaration, then default storage class is
A. Automatic B. static
#include<stdio.h>
#include<string.h>
int main()
{
char str[] = "12345\0\abcdef\0";
printf("%s\n", str);
return 0;
}
A. abcdef B. 12345
13
C. 12345 abcdef D. 12345\0abcdef
#include<stdio.h>
int main()
{
char str = "C program";
printf("%s\n", str);
return 0; }
A. Error B. C program
#include<stdio.h>
#include<string.h>
int main()
{
printf("%c\n", "abcdefgh"[4]);
return 0;}
A. Error B. d
C. e D. abcdefgh
Part-B
User defined functions are self-contained blocks of statements which are written by the user to
compute or perform a task. They can be called by the main program repeatedly as per the requirement.
14
• getchar() returns the next character typed on the keyboard
• putchar() outputs a single character to the screen
• strcat() concatenates a copy of str2 to str1
• strcmp() compares two strings
•
3. Differentiate between library function and user defined function.
Predefined functions are the functions which are already defined and stored in certain header
files. Such as scanf() printf() are predefined.
User defined functions are the functions written by user (programmer) when there is no suitable
library function available to fulfil his/her logical requirement.
A call to a function by reference using x means a reference (also called a pointer or alias) to the
variable x is passed in the function call and so any changes the function makes using this reference
will actually change the value stored in x.
Call by value passes the copy of the variable to the function that processes it whereas call by reference
passes the memory reference of the variable (pointer) to the function.
5. What is recursion?
A function that calls itself is known as recursive function and the process of calling function itself
is known as recursion in C programming.
Example
void recurse()
int main()
return 0; }
6. Define an array
15
An array is a collection of same type of elements which are stored under a common name.
A storage class defines the scope (visibility) and life time of variables and/or functions within a C
Program.There are following storage classes which can be used in a C Program
• auto
• register
• static
• extern
Declaration of a function: The declaration gives a lot of information about the function. One, it tells it
the return type. Two, it tells it how many parameters there are, and what their types are.
16
Definition of a function: The definition tell what the function does
In C, functions are global by default. The “static” keyword before a function name makes
it static. For example, below function fun() is static.
Unlike global functions in C, access to static functions is restricted to the file where they are
declared. Therefore, when we want to restrict access to functions, we make them static. Another reason
for making functions static can be reuse of the same function name in other files.
Initializing of array is very simple in c programming. The initializing values are enclosed
within the curly braces in the declaration and placed following an equal sign after the array name.
Here is an example which declares and initializes an array of five elements of type int. Array can
also be initialized after declaration. Look at the following C code which demonstrates the
declaration and initialization of an array.
int myArray[5] = {1, 2, 3, 4, 5}; //declare and initialize the array in one statement
int studentAge[4];
studentAge[0]=14;
studentAge[1]=13;
studentAge[2]=15;
studentAge[3]=16;
Strcpy() is meant to copy only null-terminated strings. It is probably implemented to copy every
byte until it encounters a #0.
strncpy() copies n bytes and it adds null termination at the end of the target string .
Two-dimensional arrays, the most common multidimensional arrays, are used to store
information that we normally represent in table form. Two-dimensional arrays, like one-dimensional
arrays, are homogeneous. This means that all of the data in a two-dimensional array is of the same type.
17
Syntax: Array Name[row][column]
The NULL character (\0) in c can be used to mark the end of a string. For Instance, the printf()
puts the next character on the screen when the NULL character is encountered. Also, NULL character
always returns FALSE in a logical test.
Void is a value of a function type that means nothing is returned. A void function has a heading
that names the function followed by a pair of parentheses. The function identifier/name is preceded by
the word void. The parameter list with the corresponding data type is within the parentheses. The body
of the function is between the pair of braces.
void functionName(DataTypeOfParameterList);
null(\0) is used for termination of string. It means each and every string ended with \0 while 0 is
a number. It represents an integer one less than 1. It is usable in all integer expressions, except as a divisor.
18. What is the difference between string constant and character constant?
A character type constant is a character, a char, while a string type is an array of characters. The
character type constant is one character and is delimited by single quotes. The string type constant is zero
or more characters and is delimited by double quotes.
18
21. Why do we need function prototypes?
A function prototype is basically a definition for a function. It is structured in the same way that
a normal function is structured, except instead of containing code, the prototype ends in a semicolon.
Normally, the C compiler will make a single pass over each file you compile. If it encounters a call to a
function that it has not yet been defined, the compiler has no idea what to do and throws an error. This
can be solved in one of two ways.
The first is to restructure your program so that all functions appear only before they are called in
another function.
The second solution is to write a function prototype at the beginning of the file. This will ensure that the
C compiler reads and processes the function definition before there's a chance that the function will be
called.
Part-C
1. Write a program to read 10 integers in an array and sort them in ascending and descending order
3. Write a program to extract a substring from a specified position containing a specified number of
characters from an input string.
7. Write a program to check whether a given number is palindrome or not using function.
Answers: (Part-A)
1. C 2. B 3. C 4. D 5. D 6. C 7. D
Unit-III Pointers
Part-A
19
a. int *ptr; b. int ptr*; c. * int ptr; d. int_ptr x;
int num,*p;
num=100;
p=#
printf("%d",*p);
int x[]={12,13,15,16};
int *p;
p=x;
p+=3;
printf("%d" ,*p);
7. What is (void*)0?
a. NULL pointer b. Void pointer c.Error d. None of above
20
Printf(“%d \n”, i**j*i+*j);
char *p;
p="hello";
printf("%s\n", *&*&p);
a. llo b. hello c. ello d. h
int m[2];
*(m+1)=300;
*m=*(m+1);
printf("%d", m [0]);
int m[2];
int *p =m;
m[0]=100;
m[1]=200;
printf("%d %d", ++*p, *p);
int a=8,b=2,c,*p;
c=(a=a+b,b=a/b,a=a*b,b=a-b);
p=&c;
printf ("\n %d",++*p);
21
a. The value *p is 46. b. The value *p is 48.
c. The value *p is 56. d. The value *p is 40.
int arr[]={0,1,2,3,4};
int i, *ptr;
for(ptr=&arr[0];ptr<=&arr[4];ptr++)
printf("%d", *ptr);
PART-B
1. What is pointer: How to access a variable through its pointer with example?
1 - int t, b, *a;
2 - t=5;
3 - a=&t;
4 - b=*a;
If a pointer variable points another pointer value. Such a situation is known as a pointer
to a pointer.
Example:
int *p1,
**p2,
v=10;P1=&v; p2=&p1;
Here p2 is a pointer to a pointer.
Array
Pointer
23
A pointer value is a data object that refers to a memory location. Each memory location
is numbered in the memory. The number attached to a memory location is called the
address of the location.
Pointer variable are defined as variables that contain the memory addresses of data or
executable code.
Uses:
• Accessing array element.
• Passing argument to function by reference.
• Passing arrays and strings to function.
• Creating data structures such as linked list, trees, graphs, and so on.
8. Explain the difference between the address operator ‘&’ and bitwise operator ‘&’ with
example?
The bitwise logical operator and (&) calculates the bitwise logical and of two integral
values. It is a binary operator.
The address of (&) operator returns the address of the value to its right. It is a unary
operator.
9. Why addition of two pointers is impossible?
The pointer holds address of another variable. Hence, addition of addresses is not
possible.
10. Explain effect of (++) and (- -) operator with pointer of all data type?
The (++) increment operator when applied with pointer it indicates next memory location
of its type. When (--) decremented it indicates previous memory location of its type.
11. What are difference between call by value and call by reference?
Call by value: When values of built in types are passed as arguments to a function. It is
known as Call by value. The changes made to formal parameters in the called function are
not reflected in the actual arguments class.
PART-C
24
5. Explain array of pointer in detail?
6. Briefly explain about
7. Give the features of pointers and explain the effect of ++ and – operator with
pointers of all data types?
8. Write a program to swap 2 numbers using pointers.
9. Program for finding the largest and smallest element in the list using pointers.
10. What do you understand by a pointer to a pointer? With suitable example.
11. Explain call by value in detail.
12. Explain call by reference in detail.
13. Demonstrate how array can be accessed using pointer syntax.
14. Write a function to convert Fahrenheit temperature to centigrade temperature call
the function using function pointer.
15. Write a program to get five subject marks using integer array, pass the array to a
function calculate total and aggregate.
Answers – (Part-A)
1.a 2.a 3.a 4.b 5.c 6.a 7.a 8.b 9.c 10.b 11.b 12.b 13.a 14.a 15.c
1.A ____ is a collection of data items under one name in which the items share the same storage.
a) Structure b) Union c)Array d)Files
2.. main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
What is the output of this program?
3. The link between a member and a variable is established using the ______ operator.
a) Member b) Pointer c) Relational d) Bitwise
25
4. Which one of the following is not valid
a) struct keyword is used to define structure template.
b) The order of values enclosed in braces must match the order of members in structure
definition
c) The uninitialized members will be assigned default values.
d)We can initialize individual members inside the structure template.
6. The ____ can be used to create a synonym for a previously defined data type
a) Struct b) Union c)Array d)Files
#include<stdio.h>
int main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0]=3;
u.ch[1]=2;
printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i);
return 0;
}
a. 3, 2, 515 b. 515, 2, 3
c. 3, 2, 5 d. 515, 515, 4
9.What will be the output of the program in 16 bit platform (Turbo C under DOS) ?
#include<stdio.h>
int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
26
}bit;
printf("%d\n", sizeof(bit));
return 0;
}
a. 1 b. 2
c. 4 d. 9
12. If one or more members of the structure are pointer to the same structure, the structure is known
as
a) Nested structure b) Invalid structure c)Self referential d)Inner structure
struct emp
{
int ecode;
struct emp *e;
};
B. Linker Error
C. No Error
D. None of above
#include<stdio.h>
int main()
{
struct a
{
27
float category:5;
char scheme:4;
};
printf("size=%d", sizeof(struct a));
return 0;
}
C No error
D None of above
15. Which of the following statements correct about the below code?
maruti.engine.bolts=25;
A. Structure bolts is nested within structure engine.
Part-B
28
5. How nested structure is declared?
Struct pay
{
Char name;
Char dept;
Int bp;
Struct inner
{
Int da;
Int ta;
Int hra;
}
Allowance;
}
employee;
7. How are structure elements assessed using pointer? Which operator is used?
The pointer variables contains the address of the separate data type ,the structure
elements assessed using pointer variable as follows:
Data_type * pointer_name;
The operator * is used for accessing structure.
Enumerated data type is an user defined data type.Enum is a keyword,which is used for
declaring enumeration types.we can create our own data type using enum and we can define
values,the variables of the data types holds
Bit fields are used to hold data items.It provides exact amount of bits required for
storage of values,to hold the information.The Bit field main intension is to reduce the memory
consumption.
29
11.How do bit fields save memory space?
In bit fields the variables that we use occupy a minimum of one byte for char and
two byte for integer.Instead of using complete integer if bits are used memory space can be saved.
Enumerated data type is an user defined data type.Enum is a keyword,which is used for
declaring enumeration types. We can create our own data type using enum and we can define
values,the variables of the data types holds
Union is similar to structure except in terms of storage and therefore it has the same syntax
as structure. Union can contain a number of members like structure but it holds only one object at a
time.
The compiler allocates storage that is large enough to hold the largest variable type in the
union. All the variables declared in the union share the same address.
Typedef is a keyword used to assign alternative names to the existing types. It helps to
declare user-defined identifiers that can be used in place of type specifiers such as int,char etc.
Part-C
1. Create structure called time_struct containing three memebers integer hour,minute and
second.Develop a program that would assign values to the memebers and display the
time in the following format 16:40:51 (S)
2. Describe with examples, the different ways of assigning values to structure memebers. (C)
3. Illustrate the cocept of nested structure with suitable syntax and example. ( C)
4. Describe three different approaches that can be used to pass structures as function
arguments. (C)
5. How the concept of union is differs from structure.Give examples for union. (K)
6. Exaplain about the steps, invovlved in defining and accessing structure memebers. (K)
7. Create a structure named date containing three integer memebers day,months and year.
Develop an intereactive modular program to perform the following tasks:
i ) To read data into structure memebers by function
30
ii) To validate the date entered by a function.( Example invalid data : 31,4,2002-April
has only 30 days, 29,2,2002- 2002 is not leap year) (S)
8. Create an union called cricket that will describe the following information:
i) player name,ii)team name,iii)bating average
using cricket,declare an array player with 20 elements and write a program to read the
information about all 20 players and print a team-wise list. (S)
9. Create a structure that can describe an hotel. It should have members that include the
name,address,grade,room charge.
write a functions to perform the following operations:
a) To print out hotels of given grade in order of charges.
b) To print out hotels with room charges less than given value. (S)
10. Explain in detail about arrays of structure with suitable examples. (C)
Answers ( Part-A )
Part-A
32
14. What will be the output of the program?
#include<stdio.h>
#define CUBE(x) (x*x*x)
int main()
{
int a, b=3;
a = CUBE(b++);
printf("%d, %d\n", a, b);
return 0;
}
a) 9, 4 b) 27, 4
c) 27, 6 d) error
15. What will the SWAP macro in the following program be expanded to on preprocessing? will the
code compile?
#include<stdio.h>
#define SWAP(a, b, c)(c t; t=a, a=b, b=t)
int main()
{
int x=10, y=20;
SWAP(x, y, int);
printf("%d %d\n", x, y);
return 0;
}
a) it compiles b) compiles with an warning
c) not compile d) compiles and print nothing
19. Preprocessor feature that supply line numbers and filenames to compiler is called?
a) Selective inclusion b) macro substitution
c) Concatenation d) Line control
20. #include are _______ files and #include “somefile.h” ________ files.
a) Library, Library b) Library, user-created header
c) User-created header, library d) They can include all types of file
33
21. A preprocessor is a program
a) That processes its input data to produce output that is used as input to another program
b) That is nothing but a loader
c) That links various source files
d) All of the mentioned
34
void m()
{
printf("hi");
}
void main()
{
max;
m();
}
a) Run time error b) hi hi
c) Nothing d) hi
35
31. What is the advantage of #define over const?
a) Data type is flexible
b) Can have a pointer
c) Reduction in the size of the program
d) Both (a) and (c)
Part-B
36
1. Define File
File is a place on the disk, where the related data are stored. To store the data
into the disk and also keep the data permanently, we need a concept called files.
5. Write a program to open a file and write some text and close it.
#include<stdio.h>
int main(){
FILE *fp;
char ch;
fp=fopen("file.txt","w");
printf("\nEnter data to be stored in to the file:");
while((ch=getchar())!=EOF)
putc(ch,fp);
fclose(fp);
return 0;
}
6. Write a program to copy the content of one file into another file.
#include<stdio.h>
int main()
{
FILE *p,*q;
char file1[20],file2[20];
37
char ch;
printf("\nEnter the source file name to be copied:");
gets(file1);
p=fopen(file1,"r");
if(p==NULL)
{
printf("cannot open %s",file1);
exit(0);
}
printf("\nEnter the destination file name:");
gets(file2);
q=fopen(file2,"w");
if(q==NULL)
{
printf("cannot open %s",file2);
exit(0);
}
while((ch=getc(p))!=EOF)
putc(ch,q);
printf("\nCOMPLETED");
fclose(p);
fclose(q);
return 0;
}
The fclose() function first flushes the stream opened by fopen() and then closes
the underlying descriptor. Upon successful completion this function returns 0 else end
of file (eof) is returned.
9. What is a preprocessor?
It is s program that processes our source program before compilation.The compiler
examines the preprocessor for any preprocessor directives. If there are any preprocessor
directives , appropriate actions are taken and then the source program is moved for
compilation.
14. Write a program to print square and cube values using macro substitution.
#define sq(n) (n*n)
#define cube(n) (n*n*n)
#include <stdio.h>
main()
{ int a=5,b=3,s,c;
s=sq(a);
c=cube(b);
printf(“\nSquare of 5 is %d”,s);
printf(“\nCube of3 is %d”,c); }
To use command line arguments in your program, you must first understand the full
declaration of the main function. Main can accept two arguments: one argument is
number of command line arguments, and the other argument is a full list of all of the
command line arguments. The full declaration of main is,
int main ( int argc, char *argv[] )
The integer, argc is the argument count. It is the number of arguments passed into
the program from the command line, including the name of the program.
The array of character pointers is the listing of all the arguments. argv[0] is the name
of the program, or an empty string if the name is not available. After that, every
element number less than argc is a command line argument. You can use each argv
39
element just like a string, or use argv as a two dimensional array. argv[argc] is a null
pointer.
20. How does a C program come to know about command line arguments?
When we execute our C program, operating system loads the program into memory. In
case of DOS, it first loads 256 bytes into memory, called program segment prefix. This
contains file table, environment segment, and command line information. When we
compile the C program the compiler inserts additional code that parses the command,
assigning it to the argv array, making the arguments easily accessible within our C
program.
The process of allocating memory at compile time is called static memory allocation and the data
requirements are know exactly
40
The main advantage of using dynamic memory allocation is preventing the wastage of memory.
This is because when we use static memory allocation, a lot of memory is wasted because all the
memory allocated cannot be utilised. Thus dynamic memory allocation helps us to allocate memory
as and when required and thus saves memory.
Part-C
1. Two data files LADIES and GENTS contain sorted list of names of girls and boys in a class
respectively. Write a program to produce a third file STUDENTS which holds the merged
list of the two given files.
2. Write a program that copies one file to another, replacing all lower characters by their
upper case equivalents.
3. Explain the functions fread(),fwrite(),fopen(),fclose() with syntax and example.
4. A file contains information about the employees of an organization. The information
includes employee number, salary and age. Write a program to count the number of
records in that file and also print the employee numbers for those who are getting
salary less than Rs.4500 and aged more than 35.
5. Explain about file with its various functions.
6. Define macro. Explain its various types with example.
7. What is preprocessor? Explain #define, #include.
8. Explain command line arguments with example?
9. Write a program to print the sum of n numbers and passing the numbers through
command line.
10. Write a program to sort the given set of numbers and pass the numbers through
command line.
11. Illustrate with an example how command line arguments are used in program.
12. Write a Program to merge 2 files using command line arguments.
13. Write a Program to count the number of characters, words, sentences and lines in a file
using command line arguments.
14. Write a program using command line arguments to copy one file in to another.
15. Explain the DMA function in c with example?
16. Write a c program to allocate memory space and reallocate the existing memory by using
the appropriate DMA function.
Answer: 1. b, 2. a, 3. a, 4. a, 5. a, 6.c, 7.a, 8.a, 9.c, 10.a, 11.a, 12.b, 13.b, 14.c, 15.c, 16.d, 17.a, 18.a,
19.d, 20.d, 21.a, 22.b,23.a, 24.b, 25.c, 26.d, 27.b, 28.d, 29.a, 30.d, 31.a, 32.c
41
42