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

cse

The document outlines a lab report on C programming, focusing on operators, expressions, and fundamental programming concepts. It includes objectives, an introduction to key topics such as arithmetic operations, conditional statements, and character functions, along with various programming exercises. The conclusion emphasizes the successful enhancement of students' coding skills and understanding of C programming principles through practical problem-solving.
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)
2 views

cse

The document outlines a lab report on C programming, focusing on operators, expressions, and fundamental programming concepts. It includes objectives, an introduction to key topics such as arithmetic operations, conditional statements, and character functions, along with various programming exercises. The conclusion emphasizes the successful enhancement of students' coding skills and understanding of C programming principles through practical problem-solving.
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/ 11

Name of The Experiment: Operators and Expressions in C programming.

Objectives:
 To gain knowledge about different types of operators.
 To practice operations of these operators.
 To gather knowledge to evaluate expressions.

Introduction:
The lab report focuses on key fundamentals of C programming that form the core of
writing efficient programs. It explores the sqrt() function from the math.h library,
used to find the square root of a given number, including its syntax and required
header file.
The report also examines conditional statements like if and else, which control the
program's execution flow based on certain conditions. It explains how these
statements evaluate conditions and execute different code blocks accordingly.
Additionally, the report covers the process of swapping values between two variables,
a common programming operation. It provides a step-by-step approach using a
temporary variable to accomplish this task.
The report delves into character functions from the ctype.h header file, such as
toupper() and tolower() for case conversion, and isalpha(), isdigit(), and isspace() for
character validation and categorization.
Furthermore, it discusses arithmetic operators in C, including addition, subtraction,
multiplication, division, and modulus. It explains the order of operations (PEMDAS)
and covers increment, decrement, and compound assignment operators essential for
mathematical calculations.
By covering these fundamental concepts, the report aims to establish a solid
foundation for understanding and applying them in various algorithms and problem-
solving scenarios within C programming.
Problem 1
Write your first program to demonstrate the working of arithmetic operators in
C.

Fig. 2.01: Code

Fig. 2.02: Output


Problem 2
Write a program to convert a given number of days into months and days.

Fig. 2.03: Code


Fig. 2.04: Output
Problem 3
Write a program to find size of integer, float, double and character of your
system.

Fig. 2.05: Code

Fig. 2.06: Output


Problem 4
Write a program to display number of days in February using conditional
operator.
Fig. 2.07: Code

Fig. 2.08: Outputs


Problem 5
Write a program to check whether a year is leap year or not.

Fig. 2.09: Code

Fig. 2.10: Outputs


Problem 6
Write a program to solve a quadratic equation.
Fig. 2.11: Code

Fig. 2.12: Output


Problem 7
Write a program to calculate the square of a value by using the function power
and also by using shorthand operator.

Fig. 2.13: Code

Fig. 2.14: Output


Problem 8
Write a program to enter two numbers from keyboard and swap the value of
these two numbers.
Fig. 2.15: Code

Fig. 2.16: Output


Problem 9
Write a C Program to compute and display remainder and quotient using only
two variables.

Fig. 2.17: Code


Fig. 2.18: Output
Problem 10
Write a C program to check whether a character is alphabet or not.

Fig. 2.19: Code

Fig. 2.20: Outputs


Problem 11
Write a C program to check whether a number entered by user is even or odd.

Fig. 2.21: Code


Fig. 2.22: Outputs
Problem 12
Write a program to check whether a character is vowel or consonant.

Fig. 2.23: Code

Fig. 2.24: Outputs


Problem 13
Write a program to convert a lowercase letter into upper case and vice versa.
F
ig. 2.25: Code

Fig. 2.26: Outputs


Problem 14
Write a C program to select the largest of three input values.

Fig. 2.27: Code

Fig. 2.28: Output


Problem 15
Write a program to calculate the value of side using the following formula:
Side =√𝒂𝟐 + 𝒃𝟐 − 𝟐𝒂𝒃 𝐜𝐨𝐬(𝒙)

Fig. 2.29: Code

Fig. 2.30: Output


Discussion:
The lab exercises provided a comprehensive introduction to essential programming
concepts in C, focusing on arithmetic operations, conditional statements, character
manipulation, and basic mathematical computations. Through the implementation of
various programs, such as demonstrating arithmetic operators, selecting the largest of
three values, converting letter cases, checking vowels and consonants, determining
even or odd numbers, checking alphabet characters, swapping numbers, calculating
squares, and solving quadratic equations, students gained practical experience in
writing and understanding C code. These exercises reinforced the importance of
logical thinking and problem-solving, illustrating how different operators and control
structures can be used to perform a wide range of tasks. Additionally, the exercises
highlighted the role of ASCII values in character manipulation and the significance of
functions in modulating and simplifying code.

Conclusion:
The lab exercises effectively demonstrated key programming principles in C,
enhancing students' understanding of arithmetic operations, conditional logic, and
character manipulation. By solving practical problems and implementing various
programs, students developed a solid foundation in C programming, preparing them
for more advanced topics and complex problem-solving scenarios. These exercises
not only improved coding skills but also fostered a deeper appreciation for the
systematic approach required in programming. Overall, the lab sessions were
successful in achieving their educational objectives, providing a strong basis for
future learning and application in the field of computer science and engineering.

You might also like