0% found this document useful (0 votes)
11 views6 pages

C Programming Lab Report - Grade XI

The lab report on C programming outlines the objectives of learning to write efficient and structured computer programs using C. It includes a table of contents with various programming tasks such as determining odd/even numbers, eligibility to vote, and calculating electricity bills. The conclusion reflects on the rewarding experience of learning C programming and the guidance received from the teacher.

Uploaded by

cherput.u
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)
11 views6 pages

C Programming Lab Report - Grade XI

The lab report on C programming outlines the objectives of learning to write efficient and structured computer programs using C. It includes a table of contents with various programming tasks such as determining odd/even numbers, eligibility to vote, and calculating electricity bills. The conclusion reflects on the rewarding experience of learning C programming and the guidance received from the teacher.

Uploaded by

cherput.u
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

TRINITY INTERNATIONAL SS & COLLEGE

KATHMANDU, NEPAL
2082

Lab –report on C-Programming (II)

(COMPUTER SCIENCE)

SUBMITTED BY: SUBMITTED TO:

NAME: Himanshu BC __________________

GRADE: XI (DH1)

STUDENT ID NUMBER: SC25-1693

STUDENT’S EMAIL: cherput.u@[Link]


Objectives:-
The primary objective of C programming is to enable us, the users, to write efficient and
structured computer programs. It provides a powerful set of commands and features that allow us
to create programs for solving problems, performing calculations, and controlling hardware.
Using C, we can write code, compile it, debug errors, and execute the program to get the desired
output. These programs can also be saved, modified later, and shared with others, who can run or
improve them using their own C compilers and development tools.

'
Table of contents

1. WAP to input a number and display it is odd or even.


2. WAP to know a candidate is eligible to caste vote or not. (age>=18)
3. WAP to input a number and display it is positive, negative or zero.
4. WAP to input two different numbers and display greater.
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 that inputs cost price (C.P.) and selling price (S.P.) and determine whether there is
loss or gain.
8. Write a program to find roots of quadratic equation ax2+bx+c=0.
−𝑏±√𝑏 2 −4𝑎𝑐
x= 2𝑎
9. The minimum charge for Nepal Electricity authority is Rs. 80 for 20 units consumed. If
electricity consumed is more than that then s/he has to pay Rs. 7.25 per unit extra up to
100. And, if electricity consumed is more than 100 units then s/he has to pay 9.50 per unit.
WAP to calculate the total bill consumed.
10. WAP to know whether, three numbers are equal or not using nested if.
11. WAP to calculate sum, difference, product and division according to user choice using
switch case.
Conclusion:
Working in the lab and classroom to learn C programming was a very interesting and rewarding
experience. Our class teacher guided us in understanding how to write, compile, and execute
programs step by step. We learned fundamental concepts such as variables, data types, operators,
loops, and functions, and we practiced writing different programs to apply these concepts. The
most exciting part was successfully running our own code and seeing the output on the screen. It
was practical, challenging, and educational. I believe this knowledge will greatly help me in
future academic studies and technical projects. I would like to thank my subject teacher for
continuous guidance and support throughout the practical sessions.

Common questions

Powered by AI

Mastering fundamental concepts, such as variables and loops, is crucial in writing effective C programs. Understanding variables is essential for handling data storage and manipulation, while loops are vital for automating repetitive tasks efficiently. The lab report emphasizes these concepts as foundational for creating structured and logical code, ensuring that students can tackle complex programming challenges with competence and confidence in their skills .

The lab report concludes that learning C programming in a classroom setting is rewarding, as it provides structured guidance on writing, compiling, and executing programs. Students grasp fundamental concepts such as variables, data types, and control statements, and gain practical experience by writing and running their own code. The direct application of these skills helps in understanding abstract programming concepts, thereby preparing students for future academic and technical challenges .

C programming enables users to write efficient and structured programs by providing a comprehensive set of commands and features which facilitate problem-solving, calculation, and hardware control. Common applications include writing code to perform calculations, solve problems, control hardware, and the ability to compile, debug, and execute programs for desired outputs. These programs can also be saved, modified, and shared with others who can run or improve them using their own C compilers and development tools .

A switch case in C simplifies user-driven operations by directing program flow based on user choices. It's particularly efficient for managing multiple potential operations without extensive nested conditions. For example, a switch case can manage arithmetic operations such as sum, difference, product, and division by matching the user's choice against defined cases, allowing the program to execute the suitable arithmetic calculation as selected by the user .

The report suggests that C programs, once written, can be saved, modified later and shared with others to enable collaboration. This encourages other programmers to run or improve the original programs using their respective C compilers and development tools, fostering a collaborative environment where shared contributions can lead to optimization and broader utility .

To find the roots of a quadratic equation using C programming, the program must use the quadratic formula: x = (-b ± √(b²-4ac)) / (2a). This formula requires calculating the discriminant (b²-4ac) to determine whether the roots are real and distinct, real and equal, or complex. The program should handle these cases through control structures, compute the discriminant, and then apply the formula to find the roots accordingly .

Nested if statements are significant in C programming for evaluating multiple conditions and making complex decisions based on those evaluations. In the lab report, the determination of equality among three numbers illustrates how nested ifs allow the program to first check one condition and, within that condition, check for another, enabling detailed logical branching. This structure ensures precise control over decision flows and accurate comparison of numbers' equality status .

The electricity billing exercise involves calculating charges based on unit consumption thresholds. For up to 20 units, a minimum charge of Rs. 80 is fixed. Beyond this, up to 100 units, each unit costs Rs. 7.25 extra. If more than 100 units are consumed, the cost per unit rises to Rs. 9.50. The program calculates the total bill by assessing these conditions, using control structures to apply the correct rate based on total consumption .

The C programs listed in the table of contents enable students to solve various real-world problems such as determining the parity of a number (odd/even), checking voter eligibility by age, categorizing numbers by their value (positive, negative, zero), comparing numerical values to find greater or middle values, and calculating academic grades through total marks and percentage. Additionally, students can assess financial gains/losses, compute potential utility costs based on electricity consumption, and perform basic arithmetic operations driven by user inputs .

C programming achieves decision-making through conditional statements such as 'if', 'else if', and 'else'. These structures allow the program to make logical decisions based on certain conditions. For instance, a program can determine if a number is odd or even, identify eligibility to vote (age >= 18), or evaluate the sign of a number (positive, negative, zero).

You might also like