0% found this document useful (0 votes)
9 views7 pages

LAB Work (1)

The document contains a comprehensive list of programming lab exercises across multiple topics including basic arithmetic operations, loops, arrays, strings, functions, structures, unions, pointers, and data file handling. Each section outlines specific tasks for students to implement, such as calculating sums, finding roots, sorting data, and manipulating strings. The exercises aim to enhance programming skills and understanding of fundamental concepts in computer science.

Uploaded by

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

LAB Work (1)

The document contains a comprehensive list of programming lab exercises across multiple topics including basic arithmetic operations, loops, arrays, strings, functions, structures, unions, pointers, and data file handling. Each section outlines specific tasks for students to implement, such as calculating sums, finding roots, sorting data, and manipulating strings. The exercises aim to enhance programming skills and understanding of fundamental concepts in computer science.

Uploaded by

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

LAB Work -1

1. WAP to find sum of two numbers.


2. WAP to find square of given number.
3. WAP to find square root of given number.
4. WAP to input your full name and print it on screen.
5. WAP to input name, age and salary and display them.
6. WAP to input a number divide it by 3 and display quotient and remainder.
7. WAP to calculate simple interest.
8. WAP to calculate area and circumference of circle.
9. WAP to input time in seconds and convert that to hour, minute and seconds.
10. WAP to calculate distance using s=ut+1/2at2
11. WAP to convert temperature in Centigrade(C) to Fahrenheit(F).
12. WAP to calculate sum of two distances and distances measured in terms of feet and inch.

LAB Work-2
1. WAP to input a number and display it is odd or even.
2. WAP to input a number and display it is positive, negative or zero.
3. WAP to input two different numbers and display greatest.
4. WAP to input three different numbers and display smallest.
5. WAP to input three different numbers and display middle.
6. WAP to input marks in five subjects calculate total, percentage and division.
7. WAP to calculate sum, difference , product and division according to user choice using switch
case.
8. WAP to input length and breadth and height and calculate area, perimeter and volume
according to user choice
*********************Menu*******************
************A-> Calculate Area******************
************P->Calculate Perimeter**************
************V->Calculate Volume****************
************E->Exit***************************
9. WAP that inputs cost price(cp) and selling price (sp) and determine whether there is loss or gain.
10. WAP to calculate and display real roots of quadratic equation.(Hint check the condition(b 2-
4ac)>0 for real root)
11. WAP to find the commission amount on the basis of sales amount as per following conditions:

Sales Amount Commision


0-1500 2%
1501-5000 5%
>5000 10%
Lab-3 Loop
th
1. WAP to print 1,3,5,… 20 term.
2. WAP to find sum of 2,4… 100th term.
2.1 count total even numbers from 1 to 100.
3. WAP to find sum of following series 1,1/2,1/3,1/4…. 1/nth term.
4. WAP to print factors of a number. E.g. factors of 6=1,2,3
5. WAP to print factorial value of a number. E.g. factorial value of 4 i.e. 4!
=4x3x2x1=24
6. WAP to print multiplication table of a number.
7. WAP to print Fibonacci series 1,1,2,3,5,… nth term.
8. WAP to know a number is Armstrong or not.
8.1 repeat same program to print all Armstrong numbers between 1 and
1000000.
9. WAP to know a number is Palindrome or not.
10.WAP to know a number is prime or not.
10.1 WAP to print all prime numbers between 1 and 100.
10.2 WAP to count total prime numbers between 1 and 100.
11. WAP to print following numeric or star patterns.
1 12345 1 5 54321
12 2345 21 54 4321
123 345 321 543 321
1234 45 4321 5432 21
12345 5 54321 54321 1

5 12345 101010
44 23456 202020
333 34567 101010
2222 45678 202020
1 1111 101010

***** 11111
**** 2222
333
*** 44
** 5
*
Lab work -4 (array)

To be familiar with array, let’s give and run following programs.

1 D Array initialization and printing some and all values.

1. WAP to input 10 elements and print them.


2. Let an array of size 200. Input any 10 elements and find total of even
numbers and their average.
3. Let an array of size 200.WAP to input 10 numbers and find maximum and
minimum values.
4. WAP to input salary of ‘n’ number of employee and display how many
employee have salary 35000-60000.
5. An array contains some elements. Search an element in that array.
6. You are given an array age[200]. Input any ten ages of persons and count
total number of persons who have age i) <=20 ii)>20 and <100
7. You are given an array age[200]. Input any ten ages of persons and print
them in sorted (Ascending and descending order) form.
8. WAP to input elements of matrix 2x2 and print them.
9. We have two matrices of order 3x3. Find their sum.
10.We have a matrix of order 3x4. Input its elements and print its elements in
transpose form.
11.WAP to input 2x3 and 3x4 matrix and display its product.
12.Suppose we have a matrix of order 3x3. Now write a program to find sum
of all diagonal elements.

Lab work -5 (string)

1) WAP to input a string and display its length.


2) WAP to input three string and display longest string.
3) WAP to input a string and display its reverse.
4) WAP to input a string and display its length without using string function.
5) WAP to input a string and display it is palindrome or not.
6) WAP to input name of 20 students and display.
7) WAP to input name of ‘n’ students and display in alphabetical order.
8) WAP to input name of 20 persons in the list. Input a name and search in the
list if found display its position.
9) WAP to input name of 20 employee and display name of those employee
whose name starts with letter ‘A’ or ends with letter ‘n’.
Lab works-6(functions)

1. WAP to find sum of two numbers using function named sum().


2. WAP to find area and perimeter of a rectangle. Use function area_perimeter().
3. WAP to know a number is even or odd using function named evenodd().
4. WAP to print multiplication table of a number using function table().
5. WAP to print the greatest value among three numbers using a function int great().
We have to use return statement.
6. WAP to know a number is prime or composite using function.
7. WAP to find sum of series 1,2,3,…..200 using function.
Assume yourself function name. It returns an integer value.
8. WAP to input elements of an array and print them with their sum. Suppose, the array is one
dimensional and is of void type and function to be used is array_elements().
9. Suppose a function string_length(char st[]).Here, we have passed string as parameter. Use this
function to find the length of string which must return the value.
10. Suppose a function void matrix_sum(int a[][],int b[][]).Here, we have passed array as parameter.
Use this function to find sum of matrices.
11. An array contains some numbers(integer type).WAP to sort numbers using a function void
sort(a[]).We have to pass that array from main function.
12. WAP to sort ‘n’ number of strings using function. Pass strings as parameter.
13. WAP to find factorial value of a number using recursive function.
14. WAP to print Fibonacci series 1,1,2,3 … 10th termusing recursive function.

Lab works-7(struct and unions)

1. WAP to input and print student id, name and grade. Use structure concept.
2. WAP to input id, name and grade for 10 students. Then print them.Use array of structure
concept.
3. WAP to input 20 employees name, position and salary. Then search a record of an employee and
its position on the basis of name.
4. We have two structures as given below.
Struct employee
{
Char ename[100];
Char eaddress[100];
};
Struct salarydetails
{
Char pos[100];
float salary;
struct employee detail;
}payinfo;
WAP to input employees’ details with salary then print them. Use nested struct concept.
5. WAP to input id,name and address of 20 students using struct. Then print them in sorted format
on the basis of name.
6. WAP to input teacher’s id,name, address and subject(any ten records). Then print them on the
basis of id. Use structure concept.
7. WAP to input any 10 student’s name, grade, gender and marks in 5 subjects. Then print all
students’ records with their name, grade, gender, total and percentage. Also print names of
those students whose gender is ‘female’.
8. WAP to input any 10 teacher’s id, name and subject using ‘typedef’ and structure. Then print
them on screen.
9. WAP using function and structure to calculate sum of two distances measured in terms of
kilometers and meters.
For example,
If we input following data
Kilometer meter
23 445
45 756
69 201
The output would be 69 km and 201 meters.
10. WAP to input student id, name and grade and print them. Use union concept.

Lab works-8(pointers)

1. WAP to perform arithmetic calculations (sum, difference, multiplication and division) of two
numbers using pointers.
2. WAP to know a number is even or odd using pointer.
3. WAP to find sum and average of ‘n’ natural numbers using pointer.
4. WAP to print 7, 22, 11, 34, 17… 10th term using function. Pass pointer to function.
5. WAP to find factorial of a number using pointer.
6. Use array to input 10 elements and print them. Use array as pointer.
7. WAP to input 10 elements and print maximum and minimum value.Use array as pointer.
8. WAP to swap two values using call by referenceand call by value.
9. WAP to sort 10 numbers stored in an array using pointer.
10. WAP to print factors of a number using pointer
11. WAP to print multiplication table of a number using pointer.
Lab works-9(Data file)

1. WAP to input a sentence and store data in a data file “file.txt”. And print them on screen. Use getc()
and putc() functions.

2. WAP to store some ‘n’ natural numbers in a data file and print them on screen. Use getw()
function.Also print their average.

3. WAP to store student’s name and address in a data file “student.txt”. Use fprintf() function.

Then read contents of datafile and print them on screen. Use fscanf()function.

4. WAP to store book’s name, edition and price in a data file “book.txt” using yes/no options. It means
the computer stores data until you say ‘n’. Then print them on screen.

5. WAP to store employee’s name, designation and salary in a data file “employee.txt” using fwrite().
The computer stores data until you say ‘n’. Then read the contents of that file and print on screen using
fread().

6. WAP to input students’ name, grade and marks in five subjects. Then store these all data with total
and percentage in a data file “student.dat”.Print all those data of students who have percentage >=80.
You may use fscanf() or fwrite().

7. WAP to show the concept of rename() and remove() functions.

8. WAP to show concept of ftell(),fseek() and rewind() functions.

Project based question (case study)

9. a.WAP to add/store some records in same data file “teacher.txt”.

b. WAP to print records stored in that data file.

c.WAP to edit particular data stored in data file “teacher.txt”.

d.WAP to delete particular data stored in data file “teacher.txt”.

e. Exit

You might also like