0% found this document useful (0 votes)
4 views4 pages

Assignment From Array,Function,Pointer,Structure,Union,DMA

The document provides a comprehensive overview of arrays, strings, functions, pointers, structures, unions, and dynamic memory allocation in C programming. It includes definitions, explanations, and C code examples for various concepts such as array declarations, sorting algorithms, search methods, and memory management. Additionally, it covers the differences between data structures and their applications in programming.

Uploaded by

Faiad Mahmud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Assignment From Array,Function,Pointer,Structure,Union,DMA

The document provides a comprehensive overview of arrays, strings, functions, pointers, structures, unions, and dynamic memory allocation in C programming. It includes definitions, explanations, and C code examples for various concepts such as array declarations, sorting algorithms, search methods, and memory management. Additionally, it covers the differences between data structures and their applications in programming.

Uploaded by

Faiad Mahmud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Array and String

1. Define array? Explain the declaration and initialization of one dimensional


and two-dimensional arrays with suitable example for 1D and 2 D array.
2. Write a C program that declares 1D array of type integer and size of array is
10. Take the input from the user and store the same in memory locations and
finally display the values stored in array along with its memory location.
3. Write a C program that will add two - 2D arrays of size 3 x 3 (i.e. no. of
rows= 3, and no. of columns =3) and display the result.
4. Compare single dimensional array with multi-dimensional array.
5. Write a C program to find the largest element in an array, assuming that the
array contains 8 elements.
6. “In C, array does not perform any bound checking.” – Comment on this and
defend your answer.
7. Write C code to declare a 4X3 integer array.

8. Define Sorting? Explain Bubble sort method with a program and example?
9. Explain Insertion sort method. Write an algorithm for the same. Write two
advantages over bubble sort.

10. Explain Selection sort method with a suitable program.


11. Explain the working of Linear Search and its algorithm with a suitable
example.
12. Explain the working principle of Binary Search with a suitable example.
13. Compare linear search and binary search with an example.
14. Define string. How string is declared and initialized? Explain string
input/output functions with an example.
15. List out all string manipulation functions. Explain any two with example.
Function

1. Explain the concept of function with actual parameter and formal


parameter.
2. What is the purpose of return type in function prototype?
3. Write a C code using
a) A function named func1, which will take one floating type 1D array,
and the number of elements in the array as inputs. The purpose of the
function is to return the maximum of the elements of that array.
b) A function named func2, which take 3 integer elements as inputs and
the purpose of the function is to display the maximum of them.
4. Write a C function name dsortarr() which will sort an array in ascending
order. Arguments of the function will be an integer 1D array containing n
elements and the number of elements in that array.
5. Write a C function avgarr() which will take an entire 1D integer array
and the number of elements as an input and returns the average of the
numbers. Just declare and define the avgarr() function.
6. What do you understand by recursion? Explain with example.
7. Write a recursive code to calculate the GCD of two integers.
8. Write a recursive C code to calculate nth term of Fibonacci Series.
9. Define a recursive C function to implement Binary Search on a sorted 1D
integer array of 6 elements.
10.Draw the recursive tree to calculate the 5th term of Fibonacci series.
11.Write a recursive C function to display the binary form of an integer.
Pointer

1. Explain the concept of pointer and double pointer with example


2. Declare a pointer which will contain the base address of your array(Pointer
to an array) with the program to display all the elements of the array by
using that pointer.
3. Explain the concept of array of pointer with example.

4. Explain the following two declarations:


i) int *ap[5];
ii) int (*ap)[5];

5. Explain the output of the following code:-


#include <stdio.h>
int main(){
int i[] = {1, 2, 3}, *p;
p = i;
printf(“%d %d”, *p, *i++);
return 0;}

6. Explain the output of the following code: -


#include <stdio.h>

int main(){
int a[] = {1, 2, 4, 6, 8}, *p;

p = a;

printf(“%d %d\n”, *p, *++p);

printf(“%d %d\n”, ++*p, *p++);

return 0;}

7. Explain the difference between Call by Value and Call by Address with
proper example.
8. Explain the permissible operations in pointer Arithmetic with proper
example.
Structure and Union

1. Explain the concept of structure and union


2. Explain difference between structure and union with an example.
3. Explain the use of structure.
4. Explain with example the array of structures. Explain whether the structure
tag name and use of struct keyword are mandatory or not.
5. Write a c program using array of structures to store data (roll number, name,
marks) of 60 students and display the students’ data.
6. Write a function in C to search by roll number and if found, display the
student’s data(the function should accept a structure variable as its
parameter).
7. Write a c program using pointer structures to store data (name ,price) of 2
books and display the data.

Dynamic memory Allocation

1. Compare between malloc() and calloc() with proper examples.


2. Write a C code to create a 1D integer array dynamically. Take some data
into it and find a particular item from the array using Linear search.

You might also like