0% found this document useful (0 votes)
55 views10 pages

Lab Programs For Practice PDF

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

Lab Programs For Practice PDF

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

1

1 Write a program to print your Bio-data.


2 Write a program in C to test the arithmetic operators.
3 Write a program to find out the simple interest and compound interest with the given input data.
2
1 Write a program to test the logical, bitwise, unary and ternary operators with the given input data.
2 Write a program to check an inputted year is leap year or not.
3 Write a program to calculate the salary of an employee given his basic pay, DA, HRA and TA.
Display the output in format of salary statement.
3
1 Write a program to enter the marks of a student in 4 subjects. Then calculate the total, Aggregate
%, and display the grades obtained by the student.
2 Write a program to enter a number from 1-7 and display the corresponding day of the week using
switch case statement.
3 Write a program using switch case that read 4 nos. and display a menu thatoffers 4 options:
calculate total, calculate average, display the smallest, and the largest number.
4
1 Write a program to check a given number is palindrome or not.
2 Write a program to generate prime numbers present between two given numbers.
3 Write a program to print the following pyramid star pattern.
5
1 Write a program that will accept an array, and find the largest number, smallest number, sum of
the elements and average of the elements present in the array.
2 Write program that will accept an array and sort the array in ascending order. Display both the
unsorted and unsorted arrays.
3 Write a program that will insert an element at a desired position of an array. Show the array before
insertion and after insertion of the new element (Array, element and position will provided by the
user)
6
1 Write a program to swap the value of two inputted variable using function. Show the initial value
and value after swapping.
2 Write a program to print the Fibonacci series using function.
3 Write a program that will accept two matrices using function and multiply them using function
and show the result using function.
7
1 Write a program to find the GCD among two given number using recursion.
2 Write a program to accept student data in a structure and display the structure elements.
3 Check a inputted string is palindrome or not using pointer.
8
1 Write a program to read and print an array of n numbers, then find out the smallest number and its
position in the array. Perform all these operations using pointer and function.
2 Write a program to implement realloc() and free().
3 Declare a pointer; allocate a block of memory to it using Dynamic Memory Allocation. Input a set
of integers to the allocated memory block. The display the set of numbers.
9
1 Write a program to implement insertion and deletion of an element using linked list.
2 Write a program to implement Push and Pop operations in Stack.
3 Write a program to implement insert and delete operations in Queue.
10
1 Write a program to implement Quick Sort algorithm using C.
2 Write a program to search an element using Linear Search algorithm.
3 Write a program to search an element using Binary Search algorithm.
C Lab Programs/Assignments for Practice
1 Assignment:
1. WAP to print “Hello PMEC EE 2nd Sem”?
2. WAP to print and display like this- PMEC:

 ++++ ++ ++ +++++ +++++


 ++++ + + + +++++ +
 + + + +++++ +++++

3. WAP to Print inverted half pyramid of numbers:

12345
1234
123
12
1
4. WAP to Print full pyramid of *:
*
**
***
****
*****
2 Assignment:-
1. Write a program to find the cube of a number?
2. Write a program to find the sum of two numbers?
3. Write a program to find the multiplication of two numbers?
4. Write a program to find addition and multiplication of two numbers?
5. Write a program to find addition and multiplication of three numbers?
6. Write a program to swap two numbers?
7. Write a program to find the area of square?
8. Write a program to find the area of rectangle?
9. Write a program to find the area of circle and circumference of circle?
10. Write a program to find the average of 5 marks of a student?
11. Write a program to convert Centigrade to Fahrenheit?

3 Assignments:
1. Write a program to show the result of two input values (int a =5 and b=2) using
arithmetic operators +,-,*,/ and %.
2. Write a program to show the use of increment and decrement operators by taking a
input variable int a=3; find x, when x=a++, x=++a, x=--a, x=a--?
3. Write a program to show the result (find a) of a input value (int b=5) using
assignment operators for expressions: a=b, a+=b, a-=b, a*=b?
4. Take two inputs and find the bitwise operations &, I, ~, ^, and shift a number by using
the operators >>,<<?
5. Write a program to find the ASCII value of a character entered?
6. Write a program to find the character for an ASCII value entered?
4 Assignment:
1. Write a program by entering a number and check whether it is even using only IF
statement?
2. Write a program to check from the three numbers entered to find the largest using
only IF statements?
3. Write a program by entering a number and check whether it is even or odd using only
IF Else statement?
4. Write a program by entering the age of a person and check whether eligible to vote or
not using only IF Else statement?
5. Write a program to check whether a character entered is Vowel or Consonant using If
Else?
6. Write a program to Design an ATM machine which only accepts the amount entered:
Rs 500, Rs 1000, Rs 1500, and Rs 2000 using If Else If statements?
7. Write a program to find the Grade of a student by entering the mark/percentage using
if else if statements (Hint: marks distribution with Grade- 90-100:O, 80-89:E,70-
79:A,60-69:B,50-59:C,40-49:D,less than 40: Fail)?
8. Write a program to check the eligibility of candidate for a particular job if he scored
50% in 10th, 55% in 12th, and 55% in B.Tech using Nested IF statements?
9. Write a program to Design an Restaurant Menu by entering the options by using only
SWITCH case (Hint:- 1:Tea, 2: Coffee, 3: Ice Cream, 4: Milk, 5: Bread, Default:
Dishes not available)?
10. Write a program to Design an Restaurant Menu by entering the options by using only
Nested SWITCH cases (Hint:- options- 1: Veg (options- 1: Veg Biriyani,2:Veg
Pulao), 2: Non Veg (Options- 1: Fish Curry, 2: Egg Curry))?
5: Class Assignments (using FOR loops only)
1. Write a program in C to display the first 10 natural numbers.
2. Write a C program to find the sum of first 10 natural numbers and find the average of
it.
3. Write a program in C to enter a number and find the total sum from 1 to that number
and find the average.
4. Write a program in C to read 10 numbers from keyboard and find their sum and
average
5. Write a program in C to display the cube of the number upto given an integer.
6. Write a program in C to display the multiplication table of a given integer.
7. Write a program in C to enter a number (hint: >10) and find the odd numbers between
1 to that number, and find the sum and average of it.
8. Write a program in C to display the pattern like right angle triangle using an asterisk
*
**
***
****
9. Write a program in C to display the pattern like right angle triangle with a number
1
12
123
1234

10. Write a program in C to make such a pattern like right angle triangle with a number
which will repeat a number in a row.
1
22
333
4444

11. Write a program in C to make such a pattern like right angle triangle with number
increased by 1
1
23
456
7 8 9 10
6 Assignment (Functions and Jumping statements)

1. Write a program to print from 4 to 20 by skipping values 5 and 7 using


continue statement.
2. Write a program to print till 4 to 11 only when the rounds start from 4 till 20
using break statement.
3. Write a program to find sum of two numbers using user defined Functions.
Hint: The function will not return any value and have no arguments.
4. Write a program to find sum of two numbers using user defined Functions.
Hint: The function will return sum value and have no arguments.
5. Write a program to find sum of two numbers using user defined Functions.
Hint: The function will return sum value and have two arguments.
6. Write a program to find average of 5 subjects using user defined Functions.
Hint: The function will return average value and have five arguments.
7. Write a program to find a number as even or odd using user defined Functions.
Hint: The function will not return any value and have one argument.
8. Write a program to swap two values using user defined Functions. The
function will not return any value and have two arguments.
9. Write a program to find the average of even numbers between 150 to 230
using user defined functions and for loop. Hint: function has average return
value and have no arguments.
10. Write a program to create a menu for Tea option and Coffee option using user
defined functions and switch case. Hint: Function will not return any value
and it has only one argument (Option).

7 Assignment (Array 1D)

1. Write a program to print the 1D array (size 5) by initializing the array first?
2. Write a program to print the 1D array (size 5) from last element to first element?
3. Write a program to find sum of the array (size 5)?
4. Write a program to find average of the array (size 5)?
5. Write a program to enter 5 values into the array using for loop find the average of
the sum of the array?
6. Write a program to find an element in an array (size 10) and display its location or
index?
7. Write a program to find the middle element of an array (odd size 5 and even size
6)?
8. Write a program to find the elements in the odd locations of an array (size 8)?
9. Write a program to count number of zeros and number of ones in an bit array
B[8]={1,0,0,0,0,1,1,0}?
10. Write a program to return the average value of an array (size 5) using functions?
Hint: the function has no arguments and average value will be returned?
11. Write a program to sort the elements of an array: srt[7]={33,42,16,12,45,57,5} in
increasing and decreasing order and display both order?
8 Assignment (Array 2D/1D)

1. Write a program to print the elements in a 2D array of size 3*3?


2. Write a program to search an element in a 2D array? (Hint: Enter the element
want to Search)
3. Write a program to add two 2D arrays of size 2*2?
4. Write a program to multiply two 2D arrays of size 3*3?
5. Write a program to find the average of a 2D array of size 3*3?
6. Write a program to swap the values of two 2D arrays of size 3*3?
7. Write a program to declare and pass an 1D array to a function and print the values
of that array at the function definition? (Hint: function has no return value and no
arguments.)
8. Write a program to return an 1D array from a function definition?

9 Assignment (Pointers and Dynamic Memory Allocation)


1. Write a program to print the value of a variable: int number=50 using a pointer
and also print the address the pointer contains?
2. Write a program to display the content in the NULL pointer?
3. Write a program to swap two numbers a=10 and b=20 using pointers and no use
of third variable?
4. Write a program to print the value of a variable: int number =50 using double
pointer and triple pointer and also print the addresses at first pointer, second
pointer and third pointer?
5. Write a program to show the increment of a pointer by 1, 2, and 3 by showing the
decimal form addresses?
6. Write a program to show the decrement of a pointer by 1, 2, and 3 by showing the
decimal form addresses?
7. Write a program to print the values and address of the values of an array using
pointers? Hint: use for loop for representation.
8. Write a program to find the sum of elements in an array using pointers? Hint: use
for loop.
9. Write a program to find the sum of two numbers a and b using Pointer to function
operation? (Hint: function returns an int value and have no arguments.)
10. Write a program to print the size of int, float, double and character ?
11. Write a program to sort the elements in an array of size 5 by allocating the
memory using malloc()?
12. Write a program to sort the elements in an array of size 5 by allocating the
memory using calloc()?
13. Write a program to reallocate space of 20 more using realloc() for an array of size
10?
14. Write a program to show the freeing of space using free()?
10 Assignment (Strings)
1. Write a program to count vowels in a string?
2. Write a program to read and print a string using gets() and puts()?
3. Write a program to enter a string and find its length?
4. Write a program to enter a string and reverse the string?
5. Write a program to copy one string into another string?
6. Write a program to concatenate two strings?

11 Assignment (Structures and Unions)


1. Write a program to enter records of 5 students such as Name, Roll No., and Mark in a
Subject using Structure “Student” and print the data of 5 students? (use array of
structure variables)
2. Write a program to find the total size taken by Structure members (for ex. Int a, float
b, etc.)?
3. Write a program to find the total size taken by Union members (for ex. Int a, float b,
etc.)?
4. Write a program to access a member of a Union using pointer and display the result of
it?

12 (Files)
1. Write a program to create a file, write in that file, and close the file?
2. Write a program to open a file, read the contents in that file (display it), and close
the file?

13 (Sorting and Searching)


1. Write a program to show linear searching while searching an element in an 1D array?
2. Write a program to show binary searching in a sorted 1D array?
3. Write a program to implement bubble sorting for a random order elements 1D array to
order in increasing manner?
4. Write a program to implement insertion sorting for a random order elements 1D array
to order in increasing manner?
5. Write a program to implement selection sorting for a random order elements 1D array
to order in increasing manner?
6. Write a program to implement Quick sorting for a random order elements 1D array to
order in increasing manner?
14 (Recursion)
1. Write a program to find factorial of a number using Recursion?
2. Write a program to print fibonacci series using Recursion?
3. Write a program to show the result of Ackerman Function?
4. Write a program to show the results of Quick sort using Recursion?
5. Write a program to show the results of Merge sort using Recursion?

15 (Linked List, Stack, Queue, )


1. Write a program to create a node of a linked list?
2. Write a program to create a linear linked list of size 5 elements (nodes) and access
each element to print the elements in the list.
3. Write a program to add an element in the first of a linked list of 3 elements?
4. Write a program to add an element in the middle of a linked list of 3 elements?
5. Write a program to add an element in the last of a linked list of 3 elements?
6. Write a program to delete an element (node) in the linked list of 3 elements?
7. Write a program to show push and pop operations in stack?
8. Write a program to enqueue and dequeue operations in linear queue using front and
rear?
9. Write a program to enqueue and dequeue operations in circular queue using front and
rear?

You might also like