c programming
DESCRIPTION
this is about c programmingTRANSCRIPT
![Page 1: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/1.jpg)
1. INTRODUCTION
Programming is the process of designing, writing, testing, debugging, and maintaining
the source code of computer programs. This code can be written in a variety of computer
languages. Some of this languages include Java, C, and Python. But in this task we will use
C++ (pronounced cee plus plus) language. C++ is a general purpose programming language.
It is designed with bias for system programming, with performance, efficiency and flexibility
of use as its design requirements. Other than that, C++ has also been found useful in many
other contexts. It has a large community including desktop applications, servers, and
entertainment software such as videogames. It has a relatively clear and mature standard. We
as human use programming languages, instead of writing directly in ones and zeros, so we
can easily write and understand the computer code and organize it. We can think of the
different kind of our code as being individual instructions that we give to the computer. Then
the computer will follows these instructions explicitly to execute our written code.
![Page 2: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/2.jpg)
2. DOCUMENTATION
2.1 PROGRAM 1 (HELLO WORLD!!)
2.1.a INPUT PROCESSING OUTPUT
INPUT PROCESSING OUTPUTprintf(“Hello World !!:\n”); “Hello World!!”
2.1.b PSEUDO CODE
1. Start
2. Display “Hello World!!”
3. End
2.1.c FLOWCHART
START
DISPLAY “HELLO WORLD!!”
END
![Page 3: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/3.jpg)
2.1.d SOURCE CODE
Source Code
2.1.e OUTPUT
Output
![Page 4: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/4.jpg)
2.2 PROGRAM 2 (SUM OF 2 NUMBERS)
2.2.a INPUT PROCESSING OUTPUT
INPUT PROCESSING OUTPUTInteger 1Integer 2
Sum = integer 1 + integer 2 Sum of 2 numbers
2.2.b PSEUDO CODE
1. Start
2. Insert first integer
3. Insert second integer
4. Sum of first and second integer is calculated
5. Display the sum of first and second integer
6. End
2.2.c FLOWCHART
START
Display the sum of first and second integer
END
Insert second integer
Insert first integer
Calculate the sum of first and second integer
![Page 5: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/5.jpg)
2.2.d SOURCE CODE
Source Code
2.2.e OUTPUT
Output
![Page 6: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/6.jpg)
2.3 PROGRAM 3 (DETRMINE AREA OF CIRCLE)
2.3.a INPUT PROCESSING OUTPUT
INPUT PROCESSING OUTPUTRadius of circle Area = pi*r1 Area of a circle
2.3.b PSEUDO CODE
1. Start
2. Enter circle radius
3. Calculate the area of circle from the value of radius
4. Area of a circle is calculated and displayed
5. End
2.3.c FLOWCHART
START
Area of a circle is calculated and displayed
END
Enter circle radius
Calculate the area of circle from the value of radius
![Page 7: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/7.jpg)
2.3.d SOURCE CODE
Source Code
2.3.e OUTPUT
Output
![Page 8: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/8.jpg)
2.4 PROGRAM 4 (CALCULATE TOTAL RESISTANCE SERIES/ PARALLEL)
2.4.a INPUT PROCESSING OUTPUT
INPUT PROCESSING OUTPUTResistance 1Resistance 2
rtotalseries = r1 + r2rtotalparallel = ((r1*r2)/(r1+r2))
Total resistance seriesTotal resistance parallel
2.4.b PSEUDO CODE
1. Start
2. Enter value of the first resistor
3. Enter value of the second resistor
4. Calculate total resistance of series and parallel
5. Value total resistance of series and parallel is displayed
6. End
2.4.c FLOWCHART
START
Value total resistance of series and parallel is displayed
END
Enter value of the first resistor
Enter value of the second resistor
Calculate total resistance of series and parallel
![Page 9: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/9.jpg)
2.4.d SOURCE CODE
Source Code
2.4.e OUTPUT
Output
![Page 10: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/10.jpg)
3. TASK 1 (PROGRAM TO CALCULATE BODY MASS INDEX (BMI)
3.a INPUT PROCESSING OUTPUT
INPUT PROCESSING OUTPUTBody weightBody height
BMI = weight (kg) / height² (m) Body mass index
3.b PSEUDO CODE
1. Start
2. Enter body weight in kilogram
3. Enter body height in meter
4. Calculate the value of BMI using equation BMI = weight (kg) / height² (m)
5. Value of BMI is displayed
6. End
3.c FLOWCHART
START
Enter body weight in kilogram
Enter body height in meter resistor
A1
![Page 11: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/11.jpg)
3.d SOURCE CODE
Source Code
3.e OUTPUT
Output
Value of BMI is displayed
END
Calculate the value of BMI using equation BMI = weight(kg) / height² (m)
A1
![Page 12: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/12.jpg)
4. DISCUSSION
a) There are three type of error that can occur when writing a program which is Syntax
Error, Run-Time Error, and Logical error.
b) Syntax Error occurs when unrecognizable or improper format of information is
entered.
c) Run-Time Error occurs when the program attempts an invalid operation such as
division by zero and it can cause the program to terminate.
d) Logical error happens when coding the program failed to solve the problems. This
error is hard to detect because you will not get any error messages and the only way
to the existence of logics errors is the production of wrong solution.
e) Text that surrounded with /* and */ is ignored by computer and it is useful to describe
the program.
f) Any variables that want to be used must declared first to avoid error.
g) Student easily get confuse the programming language with their daily life dictionary
which can makes an error in the program such as “printf” which that usually type as
“print”, “floatf” with “float”, and “stdio.h” with studio.h”.
h) All statements must end with a semicolon “(“ , ”)”
i) Integers division takes place only when both elements are integers
![Page 13: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/13.jpg)
5. CONLCUSIONS
a) Even the slightest mistake or only one letter you accidently ignored it will cause an
error to your program. Thus, make sure you have double checked your source code to
make sure it will run smoothly.
b) Two-ways communication between the program and its user is essential to make the
program working effectively. So, make sure the sentence and language that you use
as guide line in the program is easy to understand by its user.
![Page 14: c Programming](https://reader036.vdocuments.site/reader036/viewer/2022062819/577cc74a1a28aba711a08ba4/html5/thumbnails/14.jpg)