• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 62 pages
Class notes

Study materials

Document preview thumbnail
Preview 4 out of 62 pages

My documents helps to understand concept easily and important question to study in the semester,

Content preview

SRM VALLIAMMAI ENGINEERING COLLEGE
(AN AUTONOMOUS INSTITUTION)
SRM Nagar, Kattankulathur – 603 203



DEPARTMENT OF GENERAL ENGINEERING
LAB MANUAL




I SEMESTER
1901010 - ‘C’ PROGRAMMING LABORATORY

Regulation – 2019

Academic Year 2022 – 2023 (ODD SEMESTER)


Prepared by


Dr. S.K.Saravanan, AP(Sel.G) / CSE Dr. S.Parthasarathy, AP(Sel.G) / CSE




1

, SYLLABUS

1901010 C PROGRAMMING LABORATORY LTPC
004 2
OBJECTIVES:
• To develop programs in C using basic constructs.
• To develop applications in C using arrays and functions.
• To develop applications in C using Strings and Structures.

List of Programs

1. Programs using I/O statements and expressions.
2. Programs using decision-making constructs.
3. Write a program to find whether the given year is leap year or Not? (Hint: not
everycenturion year is a leap. For example 1700, 1800 and 1900 is not a leap year)
4. Write a program to perform the Calculator operations, namely, addition, subtraction,
multiplication, division and square of a number.
5. Check whether a given number is Armstrong number or not?
6. Check whether a given number is odd or even?
7. Write a program to perform factorial of a number.
8. Write a C program to find out the average of 4 integers.
9. Show how to display array elements using two dimensional array.
10. Write a C program to perform swapping using function.
11. Display all prime numbers between two intervals using functions.
12. Reverse a sentence using recursion.
13. Write a program in C to get the largest element of an array using the function.
14. Write a C program to concatenate two string.
15. Write a C program to find the length of String.
16. Find the frequency of a character in a string.
17. Write a C program to Store Student Information in Structure and Display it.
18. The annual examination is conducted for 10 students for five subjects. Write a program to
read the data and determine the following:
(a) Total marks obtained by each student.
(b) The highest marks in each subject and the marks of the student who secured it.
(c) The student who obtained the highest total marks.


TOTAL: 60 PERIODS

COURSE OUTCOMES:

Upon completion of the course, the students will be able to

• Develop C programs for simple applications making use of basic constructs, arrays and strings.
• Develop C programs involving functions, recursion, pointers, and structures.
• Design applications using sequential and random access file processing.



2

, INDEX

S.No Topic Page No
Programs using I/O statements and expressions for sum of odd and even
1.
numbers.
4
Programs using decision-making constructs
2. a). Pay Calculation. 6
b). to find if a number is negative, positive or zero.
c). to check if entered alphabet is vowel or a consonant.
Write a program to find whether the given year is leap year or Not.
3. (Hint: not everycenturion year is a leap. For example 1700, 1800 and 11
1900 is not a leap year)
Write a program to perform the Calculator operations, namely, addition,
4.
subtraction, multiplication, division and square of a number. 13
5. Check whether a given number is Armstrong number or not. 16
6. Check whether a given number is odd or even. 18
7. Write a program to perform factorial of a number. 19
8. Write a C program to find out the average height of persons. 21
Two dimensional array with height and weight of persons and compute
9. 23
the Body Mass Index of the individuals.
10. Write a C program to perform swapping using function. 25
11. Display all prime numbers between two intervals using functions. 27
12. Reverse a sentence using recursion. 29
Write a program in C to get the largest element of an array using the
13. 30
function.
14. Write a C program to concatenate two string. 32
15. Write a C program to find the length of String. 34
16. Find the frequency of a character in a string. 35
17. Write a C program to Store Student Information in Structure and Display it. 37
18. The annual examination is conducted for 10 students for five subjects.
Write a program to read the data and determine the following:
(a) Total marks obtained by each student. 39
(b) The highest marks in each subject and the marks of the student who
secured it.(c) The student who obtained the highest total marks
Create a Railway reservation system in C with the following modules
• Booking
19. • Availability checking 43
• Cancellation
• Prepare chart
Additional C Programs for exercise 49
C Language Questions and Answers Viva – Voce 58

3

, Ex.No. : 1 Program using I/O Statements and Expressionsfor sum of odd and even
numbers.
Date :

Aim

To write a C Program to perform I/O statements and expressionsfor sum of odd and even
numbers..

ALGORITHM

1. Start
2. Declare variables and initializations
3. Read the Input variable.
4. Using I/O statements and expressions for computational processing.
5. Display the output of the calculations.
6. Stop


PROGRAM
/*
* Sum the odd and even numbers, respectively, from 1 to a given upperbound.
* Also compute the absolute difference.
* (SumOddEven.c)
*/
#include <stdio.h> // Needed to use IO functions
int main()
{
int sumOdd = 0; // For accumulating odd numbers, init to 0
int sumEven = 0; // For accumulating even numbers, init to 0
int upperbound; // Sum from 1 to this upperbound
int absDiff; // The absolute difference between the two sums
int number = 1;
// Prompt user for an upperbound
printf("Enter the upper bound: ");
scanf("%d", &upperbound); // Use %d to read an int
// Use a while-loop to repeatedly add 1, 2, 3,..., to the upperbound




4

Document information

Study
Uploaded on
May 7, 2023
Number of pages
62
Written in
2022/2023
Type
Class notes
Professor(s)
Kelvin
Contains
All classes
$8.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
12
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions