You are on page 1of 4

SRI KRISHNA COLLEGE OF ENGINEERING AND TECHNOLOGY

(An Autonomous Institution, Affiliated to Anna University, Chennai)


Kuniamuthur, Coimbatore – 641 008
18CS111 – PROBLEM SOLVING USING C PROGRAMMING
QUESTION BANK FOR CIA-III

1. Write a program to calculate number of characters in a given string.


2. Describe the significance of pointers? Explain how a pointer variable is initialized?
3. Compare malloc() and calloc().
4. State the need for functions? Write the syntax for function declaration?
5. Compare actual parameters with formal parameters.
6. Define recursion?Write the syntax.
7. Difference between Structure and Union.
8. Write a c program to display an integer value for the day given by the user using enum.
9. Define typedef with a syntax.
10. Compare and contrast structure with an array
11. What is recursion?
12. Give example of self referential structure
13. Mention the various String Manipulation Functions in C.
14. What is meant by Sorting? List out any two sorting Techniques
15. Mention the various types of searching techniques in C ?
16. What are the advantages of unions over structures?
17. Differentiate call by value and call by reference.
18. Write the syntax for pointers to structure.
19. Define function.
20. Differentiate Call by value and call by reference.
21. Write a C Program to reverse a string without using inbuilt functions.
22. Explain 4 Basic String functions with example.
23. Write about enumerated data type.
24. Define self referential structures.
25. Why do we use dynamic memory allocation in c?
26. What is need for the typedef? Explain with an example.
27. What is recursion in c?
28. Write the advantages of pointer.
29. What is string constant?
30. How to return multiple values from a function?
31. Illustrate typedef with example.
32. How to access each array elements using pointers.
33. List the usage of enum with an example.
34. Create an union to specify data on students as given below and define the memory
layout if it contains Roll number, Name, Department.
35. Give the prototype of the function add that takes in two integer and
36. returns an integer.
37. What is self referential structure. Give example.

16 MARKS
1.a.Write a c program to find a given string is a palindrome or not.

b..Explain in detail about swapping of 2 numbers using Call by Value and Call by reference.

2 a.Use recursive function to calculate factorial of the given number

2.b.Describe structure in detail.Create a structure with filef name,age and phno.Write a c


program to read and print the name,age,phno of a person.

3.a.Design the function void update(int *a,int *b), which reads two integers as argument, and
sets a with the sum of them, and b with the absolute difference of them.

ANSWER:

#include <stdio.h>

void update(int *a,int *b)

int aa = *a; //STORING A VALUE IN A NEW VARIABLE TO FIND THE DIFFERENCE

*a = *a+*b;

*b = aa-*b;

int main()

int a, b;

scanf("%d %d", &a, &b);

update(&a,&b); //CALL BY REFERENCE

printf("%d\n%d", a, b);

return 0;

3.b.Define a function int max_of_four(int a, int b, int c, int d) which reads


four arguments and returns the greatest of them.

ANSWER:
#include <stdio.h>

int max_of_four(int w,int x,int y,int z);

int main()

int a=5;

int b=8;

int c=3;

int d=9;

int v;

v=max_of_four(a,b,c,d);

printf("The maximum number is:%d",v);

return 0;

int max_of_four(int a,int b,int c,int d)

int t1=(a>b)?a:b; //USE CONDITIONAL OPERATOR

int t2=(c>d)?c:d;

return (t1>t2)?t1:t2;

4.a. Given a string, S , consisting of alphabets and digits, write a program to


find the frequency of each digit in the given string.

4.b.Assume a class consisting of 60 students. Maintain a student database, where each


students having details like Roll_Number, name, Average_marks. Create a C program to
perform read and display operations on student database

//USE ARRAY OF STRUCTURE AND TRY


5.a.Write a C program to perform different categories of functions.
5.b.Differentiate structures and union

6.a.Write a C program using Menu driven to perform Swap operation using the following,
i) Call by Value ii) Call by Reference
6.b.Write a C program to find the factorial of the given number using recursive function.

7.a. Create a program that accepts an integer number and a floating point number and print their
addresses and values using pointers.
7.b. Elaborate any four String Manipulations Functions with examples.

8.aBuild a C Program finds the nth Fibonacci numbers using recursion. The first Fibonacci number is
1 and second Fibonacci is also initialized to 1 and print the series.
ANSWER:
#include<stdio.h>
int f(int x);

int main()
{
int n, i = 0, c;

scanf("%d", &n);

printf("Fibonacci series terms are:\n");

for (c = 1; c <= n; c++)


{
printf("%d\n", f(i));
i++;
}

return 0;
}

int f(int x)
{
if (x == 0 || x == 1)
return x;
else
return (f(x-1) + f(x-2));
}

8.b Build a C program to Calculate the sum of digits using the following.
i) Functions without argument and return type
ii) Functions with argument and without return type

You might also like