UNIT 5 Programing
UNIT 5 Programing
RAMAPURAM CAMPUS
FACULTY OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Sub Code/Name : 18CSS101J/ Programming for Problem Solving
QUESTION BANK FOR UNIT IV & V
PART A
Q.No Question
Comment on the following pointer declaration?
Int *ptr, p;
1 a)ptr is a pointer to integer, p is not.
b)ptr and p, both are pointers to integer.
c)ptr is pointer to integer, p may or may not be.
d)ptr and p both are not pointers to integer.
a. A pointer variable can be
b. a) Passed to a function
2 c. b) Changed within a function
d. c) Returned by a function
e. d) Can be assigned an integer value
18 What is the output of the program? #include struct student { char *c; }; void main() { struct student s[2];
printf("%d", sizeof(s)); }
a) 2
b) 3
c) 1
d) 8
What is the output of this C code?
#include <stdio.h>
int main()
{
FILE *fp = stdout;
int n;
fprintf(fp, "%d ", 45);
fflush(stdout);
19 fprintf(stderr, "%d", 65);
return 0;
}
a. 45 65
b. 65 45
c. 45
d. Compilation error
What will be the output of the program? #include struct student { char *name; }; void main() { struct
student s, m; s.name = "st"; m = s; printf("%s%s", s.name, m.name); }
a) Compile time error
20
b) no error
c) runtime error
d) stst
a. Consider the 32 bit compiler. We need to store address of integer variable to integer pointer. What will be
the size of integer pointer ?
b. A)10
21c. B)2
d. C)4
e. D)6
45. What does the following segment of code do? fprintf(fp, "Copying!");
46. a. It writes "Copying!" into the file pointed by fp
47. b. It reads "Copying!" from the file and prints on display
3148. c. It writes as well as reads "Copying!" to and from the file and prints it
49. d. . It does not writes or reads
50.
39 The size of the following union, where an int occupies 4 bytes of memory is
union demo
{
float x;
int y;
char z[10];
};
a. 8 byte
b. 4 byte
c. 10 byte
d. 18 byte
What is the correct syntax to declare a function foo() which receives an array of structure in function?
a. void foo(struct *var);
40 b. void foo(struct *var[]);
c. void foo(struct var);
d. void foo()
PART B
1. Write a C program to Pass a single element of an array into a function , entire array into a function with
sample output .
2. Write a c program for Arithmetic Operations and Incrementing Pointers
3. List any 5 pre processor directives with a sample program.
4. Explain in detail about function pointer & Array of Function Pointers with an example.
5. Explain in details with an example Void Pointer, Pointer Declaration and dereferencing pointers.
6. write a c program to count vowels and consonants in a string using pointer.
7. what is Constant Pointers and null pointer explain with an example.
8. Briefly discuss about file operations in C.
9. Write a program to copy the content from one file to another file.
10. Write a c program for file: opening, defining, closing, File Modes.
11. Explain in details about Dynamic memory allocation, malloc, realloc, free with an example.
12. Write a c program to insert a line at the end of text file.
13. Explain in details about Bit Manipulation to structure with an example.