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

Question Bank C Programming

The document covers key topics in C programming including pointers, strings, structures, unions, file handling, and preprocessors. It includes short answer and long answer questions about each topic to test understanding.

Uploaded by

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

Question Bank C Programming

The document covers key topics in C programming including pointers, strings, structures, unions, file handling, and preprocessors. It includes short answer and long answer questions about each topic to test understanding.

Uploaded by

t8ifkrir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Ch.

1 Pointers
A. Short answer questions
1. Define pointer
2. Write an example of pointer declaration and initialization.
3. What is meant by pointer dereferencing?
4. What is output of following program?
#include<stdio.h>
int main()
{
int a[] = { 1, 2, 3, 4, 5} ;
int *ptr;
ptr = a;
printf(" %d ", *( ptr + 1) );
return 0;
}
5. If a pointer variable stores address of a character variable, then what is the size of pointer?
6. Fill answers in the table based on code below-
NOTE: Address of num is 1002
int num=50, x;
int *ptr;
ptr = &num;
x=*ptr;

Variable Value
num
&num
Ptr
*ptr

7. Consider size of int=2 bytes, float=4 bytes, char= 1 byte, double=8 bytes. Fill missing values in
below table-
Data type ptr ptr++
int 1000
char 1000
float 1000
double 1000
8. List the various pointer operations.
9. What is the purpose of indirection operator?
10. What is the relationship between array name and pointer?
11. Are the expressions ptr++ and ++ptr same?
12. Write down equivalent pointer expression which does the same job as a[i]
13. List functions used in dynamic memory allocation.
14. Define dynamic memory allocation.
15. List types of pointers in C.
16. What is memory leak?
17. Define dangling pointer.
B. Long answer questions
1. What is pointer? How it is initialized explain with example.
2. Explain the concept of pointer to an array with the help of an example.
3. Explain operations on pointers with an example.
4. Write a program to Swap values of two numbers using pointers
5. Write a program to find the maximum number between two numbers using a pointer
6. Explain the concept of pointer to an array with example.
7. Explain the concept of array of pointers with example.
8. Explain difference between call by value and call by reference.
9. Explain difference between malloc() and calloc()
10. How pointers are passed as arguments to a function? Explain with example.
11. Explain function returning pointer with the help of an example.
Ch. 2 String
1. Short answer questions
1.What is string?
2. What is out put of the following C code?
void main()
{
Char *s=”hello”;
Char * p=s;
printf(“%c\t %c”, *(p+3), s[1]);
}
3.Which standard input-output library functions are used for string input and output respectively?
4. C supports string built in datatype?TRUE/FALSE.
5.What data structure is used to store a string.

2. Long answer questions

1.Explain the functions with example:


a)strrev
b)strcmp
c)strlen
d)strupr
e)strlwr
2. What is importance of NULL character in string?
3. Explain command line argument with suitable example?
4.Describe string function in c?
5. Develop a C program to calculate length of string without using standard library function.
6. Write a c program accept a string from user and check whether it is palindrome.
7. Explain any four string handling functions with usage.
8.What are command line argument? How are they declared? Give the advantage of command line
argument.
Ch. 3 Structures and Unions
1. Short answer questions
1. “A structure declaration does not use any memory”. State whether true or false.
2. Define structure.
3. Define union.
4. How structure is different from array?
5. What is nested structure.
6. What is the purpose of typedef ?
2. Long answer questions
7. How we declara and initialization of structure?
8. Explain self referential structure?
9. Differentiate between structure and union?
10. What are the similarity of structure and union.
11. Explain the term size of structure in details.
Ch4. File Handling
3. Short answer questions
4. What is file?
5. What is stream?
6. What do you mean by a text stream?
7. What do you mean by a binary file?
8. What are different modes of opening a file?
9. Which functions are used to read and write to a file?
10. What is the value of fp in below code if file a.txt does not exist?
FILE *fp;
Fp=fopen(“a.txt”,”r”);
11. What is the meaning of w+ in following C operation?
Fp=fopen(“newfile.txt”,”w+”);
12. What is the meaning of w+ in following C operation?
Fp=fopen(“newfile.txt”,”r+”);
13. What is the meaning of w+ in following C operation?
fp=fopen(“newfile.txt”,”a+”);
14. What is the meaning of following statement?
fseek(fp,4,1)
15. Long answer questions
1. Define file with its types.
2. Explain operations on file in detail
3. Compare text and binary files
4. Write short notes on 1) text and 2) binary files
5. How to open and close file? Explain with example.
6. Explain the following functions with example-
a. fseek()
b. ftell()
c. rewind()
7. Write a program to copy contents of one file to another
8. Write a program to find out number of lines, words and characters in a file.
9. Write a program to copy contents of one file to another with the case reversed.

Ch5. Preprocessors
A. Short answer questions
1. What is pre processor?
2. What are preprocessor directives?
3. What is macro?
4. Give format of preprocessor directive?
5. Which directives are used for defining a macro?
6. What is the use of file inclusion directive?
7. Define nested macro?

B. Long answer questions


1. Explain the role of C preprocessor?
2. Compare macro and function.
3. What are nested macros? Explain with example.
4. Explain the file inclusion directive?
5. Explain #define directive with example.
6. What is meant by parameterized macro. Give example.
7. What is macro? Write a program to find maximum of two numbers using macro.
8. Write a C program to find the area of a circle by using PI as macro.

You might also like