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

Programming in C Lab Exercises

The document outlines a series of programming tasks in C, focusing on console I/O, operators, and data structures. Tasks include basic arithmetic operations, prime and Armstrong number checks, array manipulations, string handling, and file operations. It also covers the use of structures and unions, recursion, pointers, and matrix operations.

Uploaded by

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

Programming in C Lab Exercises

The document outlines a series of programming tasks in C, focusing on console I/O, operators, and data structures. Tasks include basic arithmetic operations, prime and Armstrong number checks, array manipulations, string handling, and file operations. It also covers the use of structures and unions, recursion, pointers, and matrix operations.

Uploaded by

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

1.

Familiarization of console I/O and operators in C

a. Display “Hello World”


b. Read two numbers, add them and display theirsum
c. Read the radius of a circle, calculate its area and display it
d. Evaluate the arithmetic expression ((a -b / c * d + e) * (f +g)) and display
its solution. Read the values of the variables from the user through
console.

2. Read 3 integer values and find the largest among them.

3. Read a Natural Number and check whether the number is prime or not

4. Read a Natural Number and check whether the number is Armstrong or not

5. Read n integers, store them in an array and find their sum and average

6. Read n integers, store them in an array and search for an element


in the array using an algorithm for Linear Search

7. Read n integers, store them in an array and sort the elements in the array
using Bubble Sort algorithm

8. Read a string (word), store it in an array and check whether it is a palindrome word
or not.

9. Read two strings (each one ending with a $ symbol), store them
in arrays and concatenate them without using library functions.

10. Read a string (ending with a $ symbol), store it in an array and count the
number of vowels, consonants and spaces in it.

11. Read two input each representing the distances between two points in the
Euclidean space, store these in structure variables and add the two distance
values.

12. Using structure, read and print data of n employees (Name, Employee Id and
Salary)

13. Declare a union containing 5 string variables (Name, House Name, City Name,
State and Pin code) each with a length of C_SIZE (user defined constant). Then,
read and display the address of a person using a variable of the union.

14. Find the factorial of a given Natural Number n using recursive and non-recursive
functions
15. Read a string (word), store it in an array and obtain its reverse by using a user
defined function.

16. Write a menu driven program for performing matrix addition, multiplication
and finding the transpose. Use functions to (i) read a matrix, (ii) find the sum
of two matrices, (iii) find the product of two matrices, (i) find the transpose
of a matrix and (v) display a matrix.

17. Do the following using pointers


a. add two numbers
b. swap two numbers using a user defined function

18. Input and Print the elements of an array using pointers

19. Compute sum of the elements stored in an array using pointers and user defined
function.

20. Create a file and perform the following


a) Write data to the file
b) Read the data in a given file & display the file content on console
c) append new data and display on console

21.Open a text input file and count number of characters, words and lines in it;
and store the results in an output file.

You might also like