Screenshot 2024-12-08 at 8.42.12 PM
Screenshot 2024-12-08 at 8.42.12 PM
UNIT-II
1. What is the difference between a for loop and a while loop?
2. How do you pass parameters to a function in C?
3. Write a C program to print prime numbers using iterative statements
4. What is the general form of function?
5. Write a C program to write sum of two numbers using with return type and without
arguments.
6. How many 'a' will be printed when the following code is executed?
#include <stdio.h>
int main()
{
int i = 0;
char c='a';
while (i < 5)
{
i++;
switch (c)
{
case 'a':
printf("%c", c);
break:
}
}
printf("a\n");
return 0;
}
7. How do you declare a one-dimensional array in C?
8. What is a recursive function in C?
9. Give the general form of array declaration.
10. How do you access elements of a two-dimensional array in C?
PART-B
11. Explain if, if-else, nested if-else and cascaded if-else with examples and syntax.
12. i. Explain the different types of loops in C with syntax.
ii. Show how break and continue statements are used in a C-program, with example.
13. What is an array? How a single dimension and two-dimension arrays are declared and
initialized?
14. Explain in algorithm and write a C program to reorder a one-dimensional array of numbers in
descending order.
15. What is the difference between pass by value and pass by reference? Write the C coding for
swapping two numbers using pass by reference?
16. What is recursion? Write a C program to display Fibonacci series using Recursive function.
17. Explain the purpose of function prototype. And specify the difference between user defined
and built-in functions.
18. Write a C program to implement a simple banking system using functions and arrays.
UNIT-III
1. What is a string in C?
2. What is the difference between a string and a character array in C?
3. What is the purpose of the strlen() function in C?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
int *p = arr;
int i;
for (i = 0; i < 5; i++) {
printf("%d ", *p);
p++;
}
return 0;
}
PART-B
1. Write a C program to reverse a string without using string handling functions.
2. Write a C Program to find length of a string without using library functions.
(ii) Write a C program to check whether a given string is a palindrome.
3. Write the following programs:
To sort the given set of strings alphabetically.
Write a C program to find transpose of a matrix.
UNIT-IV
1. Define typedef with syntax and an example.
2. Give the syntax for structure and its definition.
3. Write the rules for declaring a structure.
4. Write the three ways to pass structure variables as argument to a function.
5. How structure elements can be accessed?
6. Define nested structure.
7. What is an enumeration? Give an example.
8. Why do we need Union in C programming?
9. Differentiate Structure and Union in C.
10. What is the output for the below program?
#include <stdio.h>
enum Color {RED, GREEN, BLUE};
int main() {
printf("RED = %d\n", RED);
printf("GREEN = %d\n", GREEN);
printf("BLUE = %d\n", BLUE);
return 0;
}
PART-B
1. What is a structure? Create a structure with data members of various types and declare two
structure variables.
2. i. Explain the concept of structure within structure with suitable program.
ii. Define and declare a structure to store date, which includes day, month and year.
3. Discuss about any two possible ways of passing structures to function.
4. Explain how members of a Structure are accessed using a program code.
5. Explain union of structure Give an example also mention the size of memory that will be
allocated for your example.
6. Explain Structures inside Union and Union inside Structures with example.
7. What are self-referential structures? Explain with suitable examples.
8. Implement a union BankAccount with members Account no, balance and Account holder.
Write a C Program to perform banking operations (Deposit, Withdraw and Check
Balance)
UNIT-V
1. What is a file?
2. How do you open a file?
3. Mention any five file functions.
4. What is sequential access file?
5. Write a program in C language to create a data file.
6. What do you mean by Command line arguments?
7. Define file pointer in C.
8. Compare text file and binary file.
9. What are the basic operations performed on a file?
10. Why files are needed?
PART-B
1. Explain the types of file processing with necessary examples.
2. Write the case study of “How sequential access file is differing from random access file”.
3. Write a program that appends one file at the end of another.
4. Explain in detail random access in files along with the functions used for the same in C.
Give suitable examples.
5. What is dynamic memory allocation? Explain various C functions that are used for
dynamic memory allocation with examples.
6. Distinguish between static memory allocation and dynamic memory allocation in C.
7. Distinguish between malloc() and calloc() functions in C.
8. Write a program that will receive a filename and a line of text as command line arguments
and write the text to the file.
PART-C