Sie sind auf Seite 1von 9

C PROGRAMMING LAB PROGRAMS

Total: 12 Weeks

Note: Each lab contains total 8 programs.5 for lab Exercise and 3 for assignment.

And ‘*’ represents for programs in Record.

Week 1: UNIT -1 : BASIC C -PROGRAMS


1. Write a C-program to print welcome message

*2.Write a C-Program to find the average of three integer values

3. Write a program to find the distance travelled by an object (i.e s=ut+ (1/2)at2)

4. Write a Program to find the roots of a Quadratic Equation.

5. Write a program to find the simple interest.

Assignment:
*1. Write a program to swap two values without using temporary variable.
2. Write a program to convert Fahrenheit to Celsius using the formula: C = (F−32)/1.8

3. Write a program to read the values of x, y and z and print the results of the following
expressions in one line.
a = (x+y+z)/(x−y−z), b = (x+y+z)/3 , c = (x+y)*(x-y)*(y-z)

Week 2: UNIT-1: C - OPERATORS


1. Write a program to add two times.(ex: 3:40 and 1:40 so total time 5:20)

*2. Write a program to which reads 3 student marks and find the average marks of the passed
students only

*3. Write a program to find the maximum between three integers using conditional operator.
4. Write a program to check the given character is lowercase, uppercase, digits or others.

*5. Leap year

Assignment:
1. Write a program to print the grade of the student as follows (use relational operators only)

if m>=60 print grade as 1 if m>=50 and m<60 print grade as 2

if m>=40 and m<50 print grade as 3 if m<40 print grade as 4

2. W a p which reads three integers and check whether last 2 values are factors to the first value
or not

3. Write a Program to convert no. of days into no. Of years, no.of months and no. Of days

Week 3: UNIT-2: IF AND SWITCH STATEMENTS


1. Write a program to find the maximum between three integers.

*2. An electric power distribution company charges its domestic consumers as follows:

Consumption Units Rate of Charge


0-200 Rs. 0.50 per unit
201-400 Rs.100 plus Rs.0.65 per unit excess 200
401-600 Rs.230 plus Rs.0.80 per unit excess of 400.

Write a C program that reads the customer number and power consumed and prints the amount
to be paid by the customer.

3. Admission to a professional course is subject to the following conditions:


i. marks in maths >= 60.
ii. marks in physics >= 50.
iii. marks in chemistry >= 40.
iv. total in all three subjects >= 200.

Given the marks in three subjects, write a C program to process the application to find whether
eligible or not.

4. Write a program to print the grade of the student as follows:

If m>=60 print grade as FIRST If m>=50 and m<60 print grade as SECOND

If m>=40 and m<50 print grade as THIRD If m<40 print grade as FAILED
*5. Wap to perform arithmetic operations using switch statement.

Assignment:
*1. Wap to find the roots of a Quadratic equation by checking necessary conditions.

2. A cloth showroom has announced the following seasonal discounts on purchase


of items:
Purchase amount Discount
Mill items Handloom items
0-100 - 5%
101-200 5% 7.5%
201-300 7.5% 10.0%
above 300 10.0% 15.0%

Write a C program to read purchase extent and calculate discount. Also print the purchase
amount and discount.

3. Candidates have to score 90 or above in the IQ test to be considered eligible for taking further
tests. All candidates who do not clear the IQ test are sent reject letters and others are sent call
letters for further tests. Write a program to Represent the logic for automating this task.

Week 4: Unit-3: LOOPS


1..Write a program to find the factorial of a given number

*2. Write a program to find the sum of individual digits of a given number.

3. Write a program which reads n student marks and finds the maximum1 and maximum2
marks.

*4. A Fibonacci sequence is defined as follows: the first and second terms in the sequence are 0
and 1. Subsequent terms are found by adding the preceding two terms in the sequence. Write a C
program to generate the first n terms of the sequence.

5. Write a program to find the gcd of the given 2 numbers.

Assignment:
*1. Write a C program to generate all the prime numbers between 1 and n, where n is a value
supplied by the user

2. Write a program print the perfect numbers between 1-1000


*3. Write a C program to calculate the following Sum:

Sum=1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10!

Week 5: UNIT-4: ARRAYS


1. Write a program to check whether the two strings are identical or not.

2.2’s complement of a number is obtained by scanning it from right to left and complementing
all the bits after the first appearance of a 1. Thus 2’s complement of 11100 is 00100. Write a C
program to find the 2’s complement of a binary number.

3. Write a program which reads n student ids and marks and print the id of the student who got
max marks.

*4. Write a program to find both the largest and smallest number of an array of integers.

*5. Write a program for Matrix multiplication by checking compatibility

Assignment:
1. Write a C program that uses functions to perform the following operations:

i. To insert a sub-string in to given main string from a given position.


ii. To delete n Characters from a given position in a given string.
iii. To replace a character of string either from beginning or ending or at a specified
location

*2. Write a program to count the lines, words and characters in a given text.

3. Write a program to find the inverse of a given matrix.

Week 6:UNIT-5:FUNCTIONS AND RECURSIVE FUNCTIONS


1. Write a function which takes an integer value as an argument and find ncr value.

2. Write a function to interchange two integer values.(call-by-value technique)

*3. Wrte a function which takes the sides of the triangle(a,b,c) as arguments and return the Area
of triangle(Area=sqrt(s*(s-a)*(s-b)*(s-c))
4. Write a program to find the power (a, b) using recursion.

*5. Write a program to find the factorial of a given number using recursion

Assignment:
1. Write a function to return the value of the following function. Square(m( )+n( ) )

2. Write a program to print the Fibonacci series using recursion.

*3. Write a program find the GCD (greatest common divisor) of two given integers using
recursion.

Week 7: UNIT-5: FUNCTIONS USING 1D AND 2D ARRAYS


1. Write a function which takes a string as an argument and returns its length.

*2. Write a function which takes 1d integer array as an argument and return the sorted array.

*3.Write a function to search an element in the given 1d integer array.

4.Write a function to return the lucky number of a given number.(ex:19=(1+9=10)=(1+0=1))

5.Write a function which takes an odd square matrix as an input and return the sums of
individual blocks as follows:

* * * *

* * * *

* * * *

* * * *

Assignment :
1. Write a function which takes 1d integer array as an argument and return the maximum value

2. Write a function which takes a matrix as an argument and return its transpose

*3. Write a C function to generate Pascal’s triangle.


Week 8:UNIT-6:POINTERS AND FUNCTIONS
*1. Write a program to copy the string into another string using pointers.

2. Write a function which takes a string as an argument and return the no. of lower cases, no.of
upper cases, no.of digits and others.

*3. Write a program for Pointer based function to exchange value of two integers using passing
by address

4. Write a function which takes a string as an argument and return its length.

*5. Waf which takes a 2 matrices as an arguments and return its addition

Assignment:
1. Wap to check the given string is palindrome or not.

2. Write a function to check the given matrix is symmetric matrix or not using pointers

3. Write a function which takes a matrix as an argument and return the sum of elements of
middle row ,and sum of elements of middle coloumn.

Week9:UNIT-6:DYNAMIC MEMORY ALLOCATION


1. Write a program to find the max value of the given 1d integer array allocate the memory
dynamically at run time(using malloc( ))

2. Write a program to find the sum of 1 d integer array(using malloc( ) )

*3. Write a program to subtract two matrices(using pointer to pointer technique)

4. Write a program to find the sum of elements of lower triangular matrix(using array of pointers
technique).

*5. Write a program to find the sum of elements of principal diagonal and other diagonal
elements(using pointer to pointer technique).

Assignment:
*1. Write a program to print the elements in reverse order stored in 1d array.(using malloc( ))
2. Write a program to find the sum of elements of upper triangular matrix(.using array of pointers
technique)

3. Write a program to find the sum of elements of middle row and middle column of of the odd
square matrix.(pointer to pointer technique)

Week10:UNIT-7:STRUCTURES ,FUNCTIONS AND ARRAYS


1.Define a structure with the name student which contains sno,sname,marks.wap to read 2
students information and print the details of the student who got maximum marks.

*2.Define a structure with the name student which contains sno,sname,marks.wap to read and n
students information and print the details of the students whose marks greater than or equal to
average marks of the students.

3.Define a structure with the name student which contains sno,sname,marks.wap to read n
students information and print the details of the students in asenending order.

4.Define a structure with the name complex which contains rael part and imaginary part.write the
functions to add, subtract and multiply two complex numbers using returning as an complex
number.

5.. Define a structure with the name Date which contains day,month,year. Write a function which
takes two dates as an arguments print the largest date.

Assignment:
1. Write a C program which generates array of structures, each structure represents an “item”
which contains item code, item name, stock in hand, unit price. Read n items information from
the keyboard. Given item code and quantity to be purchased. Calculate and point total price
along with other details.

* 2.Write a C program to compute the monthly pay of 100 employees using each employee’s
name, basic-pay. The DA is computed as 52% of the basic pay. Gross-salary (Basic-
pay+DA).Print the employees name and gross salary.

3. Write a C program using structure to create a library catalogue with the following fields;
Access number, author’s name. Title of the book, year of publication, publisher’s name, price.
Week11:UNIT-7:STRUCTURES , POINTERS,NESTED STRUCTURES
*1. Write a function to compare two structure variables.

*2. Write a function to copy the contents of one student into another student record Of same
type.

3. Write a function which takes a student structure as an argument and modify the original
student details using pointers.

*4. Write the functions to add, subtract and multiply two complex numbers using pointers.

5. Write a C program to store the information of vehicles. Use bit fields to store
the status information. Assume the vehicle object consists of type, fuel and model
member fields. Assume appropriate number of bits for each field.

Assignment:
1. Write a program to print the details of the student using pointers.

2. Write a program to print college and students information by nesting the students structure in
college structure.

3. Write a program to use structure within union. Display the contents of structure elements

Week 12:UNIT-8:FILE HANDLING


1.Write a program to copy the contents of one file into another file.

2. Write a program to count the number of words, lines and characters in the given file.

3. Write a program to copy n student records into a file and read all the records from the copied
file and print the records of the students on the monitor hose marks are greater than or equal to
70 by reading the data from the file..

*4.Wap to display the total price of each item by reading the data from a file as follows:

Item code Item Name Quantity Price

101 pencil 50 Rs.3/-

102 pen 100 Rs.5/-


*5. Wap which reads set of files as an input from the command line and copy the contents of first
file into second file, and 3rd into 4th and 5th into 6th and soon. (Condition: if the no. of files are odd
copying should not takes place)

Assignment:
*1 .Write a program to print the data of the file onto the monitor in reverse order.

2. Write a C program to read numbers from a file DATA, contains a series of integer numbers,
and then write all odd numbers to a file to be called ODD and all even numbers to a file to be
called EVEN.

3. Write a program to print the last n characters in the given file.

 Record programs = 35

 Total programs = 96

Das könnte Ihnen auch gefallen