100% found this document useful (2 votes)
2K views

C in Depth Solution

This document contains 10 programming assignments for a C programming lab at Motilal Nehru National Institute of Technology in Allahabad, India for the even semester of 2017-2018. The assignments involve sorting arrays with pointers, defining and working with structures, adding values between different measurement systems stored in structures, passing an entire structure as a function parameter, dynamic memory allocation to modify array sizes and find largest elements, and taking and returning a matrix from a function to calculate the sum of elements.

Uploaded by

Avinash Jha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
2K views

C in Depth Solution

This document contains 10 programming assignments for a C programming lab at Motilal Nehru National Institute of Technology in Allahabad, India for the even semester of 2017-2018. The assignments involve sorting arrays with pointers, defining and working with structures, adding values between different measurement systems stored in structures, passing an entire structure as a function parameter, dynamic memory allocation to modify array sizes and find largest elements, and taking and returning a matrix from a function to calculate the sum of elements.

Uploaded by

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

Motilal Nehru National Institute of Technology, Allahabad

Computer Science & Engineering Department


Even Semester 2017-18

C Programming Lab (Assignment 6)

1. Write a C program to sort an array using Pointer.


2. Define a structure type, struct personal that would contain person name, date of joining and
salary. Using this structure, write a program to read this information for one person from keyboard
and print the same on the screen.
3. Create two structure named metric and british which store the values of distances. The metric
structure stores the values in metres and centimetres and the british structure stores the values in
feet and inches. Write a program that reads values for the structure variables and adds values
contained in one variable of metric to the contents of another variable of british. The program
should display the result in the format of feet and inches or metres and centimetres as required.
4. Write a C program to illustrate the method of sending an entire structure as a parameter to a
function named “total_sum()”:
Create a structure named marks having five structure members for different subject marks, then
send the entire structure from main() to function “total_sum()” and in this function find the total
subjects mark.
5. Write a C program to store ‘n’ elements in a block of memory space created by malloc and then
modify the same to store ‘2n’ elements.
6. Write a C program to input and print text using Dynamic Memory Allocation.[ create memory for
text string at run time using malloc() function, text string will be inputted by the user and
displayed. Using free() function release the occupied memory.]
7. Write a program in C to find the largest element of ‘n’ elements using Dynamic Memory
Allocation.
8. Write a C program to read a one dimensional array, print sum of all elements along with inputted
array elements using Dynamic Memory Allocation.
9. Write a C program to read and print the student details using structure and Dynamic Memory
Allocation.
10. Write a program in C to take a matrix in function named ‘func()’, then return entire matrix in
‘main()’ and in main() find & display the sum of all matrix element.

You might also like