Computer Lab Report (Input Output Function)(2081-08-04)
Computer Lab Report (Input Output Function)(2081-08-04)
KATHMANDU, NEPAL
2024
Lab-report on C-Programming
(COMPUTER SCIENCE)
1
TRINITY INTERNATIONAL SS & COLLEGE
Lab report #4
(Input/Output Function)
2
Acknowledgement
I would like to express my deepest gratitude to Achyut Shah Thakuri for his continuous
guidance, encouragement, and support throughout this project. His insightful suggestions,
valuable expertise, and dedication played a crucial role in the successful completion of my
project on Input/Output Function in C-Programming. I am sincerely thankful for the opportunity
to learn under their mentorship.
I also extend my appreciation to Trinity International SS & College for providing the necessary
tools and resources that made this project possible. The access to research materials, libraries,
and technical support greatly contributed to the quality of my work.
Lastly, I am grateful to Janak Mahara for his assistance during the course of this project, ensuring
that I was able to execute it successfully. His support in providing the technical foundation was
highly valuable.
3
Objectives
The main objective of this project is to demonstrate the practical use of input/output functions in
C programming to handle data input and display outputs effectively. It focuses on using functions
like scanf () and printf () to create interactive programs where users can provide inputs, and the
results are displayed in a clear and organized manner. By showcasing the application of these
functions, the project highlights their importance in making programs easy to use and
understand.
Another key objective is to show how input/output functions are essential for building more
advanced programs. Through examples such as formatting outputs, managing different types of
data, and ensuring smooth and error-free input handling, the project illustrates how these
functions are used to develop programs that are both efficient and reliable. This section
emphasizes their role in connecting user inputs with program logic, which is a vital part of
programming.
Overall, the project aims to improve understanding of how input/output functions work in C
programming. It demonstrates how these functions make it possible to create user-friendly,
interactive, and error-free programs while laying a strong foundation for learning more advanced
programming concepts.
4
Table of Contents
(Input/Output Function)...................................................................................................................2
Acknowledgement...........................................................................................................................3
Objectives........................................................................................................................................4
Theory..............................................................................................................................................6
1. Write a program to input three numbers and find sum and average........................................8
8. Write a program to convert total numbers of seconds into hours, minutes and seconds.......22
Conclusion.....................................................................................................................................24
5
Theory
The scanf () function allows the program to accept user input in various formats, such as integers
(%d), floating-point numbers (%f), and strings (%s). This makes it suitable for applications
requiring user-provided data, like calculators or data-entry systems. Proper input validation
ensures smooth execution without errors.
The printf () function is used to display outputs, such as results, messages, or formatted data, to
the screen. With format specifiers, it offers flexibility in presenting information, like controlling
decimal places or aligning text for clarity.
These functions are versatile and can handle complex input/output tasks, including character-
based operations with getchar () and putchar(). They form the backbone of user interaction in C
programming and are essential for developing efficient and user-friendly applications.
6
7
1. Write a program to input three numbers and find sum and average.
8
2. Write a program to find area and circumference of circle.
9
10
3. Write a program to the square root and cube root of a number.
11
12
4. Write a program to find simple interest and net amount.
13
14
5. Write a program to convert centigrade into fahrenheit. (f=1.8c+32)
15
16
6. Write a program to find the value of s where s=ut+(1/2)*at2
17
7. Write a program to find TSAof Cuboid [2(lb+bh+hl)]
18
19
8. Write a program to convert total numbers of seconds into hours,
minutes and seconds
20
21
Conclusion
This project has provided a clear understanding of the practical use of input/output functions in C
programming for creating interactive and user-friendly applications. Through examples that
utilized functions like scanf () and printf (), the project demonstrated how programs can
effectively take input from users and display results in a structured manner. This highlighted the
importance of these functions in simplifying user interaction and ensuring clarity in program
output.
The project also illustrated how input/output functions are foundational for developing more
advanced programs. By exploring concepts such as formatting output, managing various data
types, and ensuring error-free input handling, it showed how these functions contribute to the
22
efficiency and reliability of programs. This reinforced the idea that input/output functions are not
just basic tools but essential components for connecting program logic with user interaction.
23