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

Module 5

The document outlines a series of programming tasks in C, focusing on the use of pointers, dynamic memory allocation, and various algorithms such as matrix operations, string manipulations, and data structures. Each task includes specific requirements, such as implementing functions for matrix multiplication, managing arrays, and performing file operations. Additionally, optional questions explore advanced topics like function pointers and comparing arrays.

Uploaded by

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

Module 5

The document outlines a series of programming tasks in C, focusing on the use of pointers, dynamic memory allocation, and various algorithms such as matrix operations, string manipulations, and data structures. Each task includes specific requirements, such as implementing functions for matrix multiplication, managing arrays, and performing file operations. Additionally, optional questions explore advanced topics like function pointers and comparing arrays.

Uploaded by

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

SR NO Question 1 Question 2 (Optional)

Write a program in C to accept dimensions of two matrices and to check if


1 matrix multiplication is possible, if it is possible then multiply two matrices
using pointers.
Design a function that:

Defines a structure Book with members title, author, and price.


2 Dynamically allocates memory for an array of Book structures using malloc().
Initializes the structure members using user input.
Prints the details of all books.
Frees the dynamically allocated memory after use.
Write a program in C to print all permutations of a given string using pointers.
Expected Output :

3 The permutations of the string are :


abcd abdc acbd acdb adcb adbc bacd badc bcad bcda bdca bdac cbad
cbda cabd cadb cdab cdba db
ca dbac dcba dcab dacb dabc
4 Write a program to implement matrix addition and subtraction using pointers. Write a program to count the frequency of a specific word in a file.
Write a C program to search an element in an array using pointers.
Input: Enter size of array: 10
5 Enter elements in array: 10 20 30 40 50 60 70 80 90 100
Enter element to search: 30
Output: 30 is found at 3 position.
6 Write a program in C to transpose a matrix using pointers. Write a program in C to reverse a string using pointers.
Write a C program that dynamically allocates memory for an array of integers.
Allow the user to input the size of the array, allocate memory, input values, and
7 then ask the user if they want to resize the array. Reallocate the memory
dynamically if the user chooses to add more elements, and maintain the
previous values in the new array.
Write a function to compute the distance between two points
A 5-digit positive integer is entered through the keyboard,
and use it to develop another function that will compute the
write a function to calculate sum of digits of the 5-digit
area of the triangle whose vertices are A(x1, y1), B(x2, y2),
8 number:
and C(x3, y3). Use these functions to develop a function
(1) Without using recursion - call by reference
which returns a value 1 if the point (x, y) lines inside the
(2) Using recursion
triangle ABC, otherwise a value 0.
Write a program to dynamically allocate memory for an array of integers and
9 Create a program to reverse a string using pointers.
input values into it.
Write a program in C to swap two integers using pointers. Define a function
10 that accepts two integer pointers, swaps their values, and displays the result in
the main function.
SR NO Question 1 Question 2 (Optional)
Write a program to pass arguments to a function by reference and to another write a program to show that pointers can be used to return multiple values
11
function by value and show how they differ. from a function without having to explicitly mention them as return values.
Write a program in C to store n elements in an array and print the elements
12
using a pointer.
Write a program in C to find the largest element using Dynamic Memory
13 Write a C program to copy one string to another using pointers.
Allocation.
Design and implement a C program to manage a dynamic array of integers.
The program should allow the user to:

Insert an integer at any position in the array.


14 Delete an integer from any position in the array.
Display the elements of the array.
The program should dynamically allocate memory for the array using malloc()
and reallocate memory using realloc() as needed to accommodate insertions
and deletions
Given three variables x, y, z write a function to circularly shift their values to
15 right. In other words if x = 5, y = 8, z = 10, after circular shift y = 5, z = 8, x
=10. Call the function with variables a, b, c to circularly shift values.
16 Write a C program for dynamic memory allocation using malloc and free Write a C program to modify elements of an array using pointers
Write a program that defines a structure Student with name, roll_no, and an
17 array marks[5]. Dynamically allocate memory for marks[] based on the number
of subjects. Implement functions to input and display student data.
Dynamically allocate a MxN matrix using malloc().
Implement functions to:
18 a) Accept and display matrix elements.
b) Compute the transpose of the matrix without using extra memory.
Free the allocated memory properly.
19 Write a program in C to find the factorial of a given number using pointers.
Write a C program that:
Opens a file in write mode and writes a series of numbers (1 to 10) to the file.
20 Closes the file and reopens it in read mode.
Reads the numbers from the file and computes their sum.
Displays the numbers and their sum.
Write a program that:
Dynamically allocates an array of N integers.
Uses pointer arithmetic to:
21
1) Reverse the array without using extra space.
2) Find the maximum and minimum values.
3) Sort the array using pointer-based bubble sort.
SR NO Question 1 Question 2 (Optional)
Write a program in C to check Armstrong and Perfect numbers using the
22
function.

Write a C program to demonstrate the use of pointers in function arguments.


Your program should:

1. Define a function `swap(int *a, int *b)` that swaps the values of two integers
23 using pointers.
2. In the `main()` function, take two integer inputs from the user and call the
`swap()` function.
3. Display the values before and after swapping.

Implement a calculator using function pointers.


Create separate functions for addition, subtraction, multiplication, and division.
24
Store function pointers in an array and call functions dynamically based on
user input.
write a program tp read the details of a student and then print it on the screen
25
as well as write it into a file
Write a function (using pointer parameter) that compares two integer arrays to
Write a program using pointers to compute rhe sum of all interger elements
26 see whether they are identical. The function returns 1 if they are identical and 0
stored in an array.
otherwise.
Write a program that takes two strings as input and concatenates them using
27
pointers. Don't use standard library functions for string manipulation.

You might also like