Coding Explanation 1
Coding Explanation 1
#include<stdio.h> : This can be defined as a library where the printf() and scanf() functions are stored. It
is usually used as first source-code when writing a program so it can be easy to program.
#include<conio.h> : This is also a library where functions like clrscr, getch(), getc() etc. can be got from.
This is included as second after writing #include<stdio.h> so it can be easy to end the program or put an
end to the programming.
Note that the .h at the end of stdio and conio is known as HEADER.
Int main() : stands for integer main and it means that the function returns an integer value. In this stage,
why we put this is because integers can be repeated many times.
; The semi-colon is used as a “full-stop”. So when you use it in a program it will tell the compiler to stop
and make that particular function to be executed. The function of the “;” is that it will end the statement
or the input/output command.
It is mostly or commonly used with printf(), scanf(), return(), getch(), void main etc.
{} : This is known as loop. This function helps the structure of the program look simple and allows the
program to be easily executable by the compiler. When using this curly braces in c programming, the
curly braces must open at first and then close as the end of the program.
%d : This is known as integer. This symbol “%d” is used to input integer values (without decimals). It is
mostly used with scanf(). When using it, it is must be written as scanf(“%d”, & “what you are
addressing”).
Let us say you want the user to input value for a variable such as k = anything. So when you are to write it
you will write as scanf(“%d”, &k). why we need to put & is because we are trying to tell the compiler
that the inputted value is for k.
Printf() : As initially said that this printf() is derived from #include<stdio.h>. Now, what printf() does is that
it output data written.
1. #include<stdio.h>
2. int main()
3. {
4. printf(“\nwe have successfully completed our project. \n”);
5. return(0);
6. }
printf() will make the quotation “we have successfully completed our project” written in it to be displayed
as output so we as human can read it and will be able to understand what the program it all about.
Note that when using printf() in a c program. The double apostrophes serving as quotation sign must be
included so that the compiler can execute it as an output depending on what was written. And for \n it is
your choice to include it but a very good/professional program will always included for clarity. We will get
to know more about the function of \n later.
Scanf(): As we said that printf() and scanf() are from #include<stdio.h>. Since we said prinf() can only
output then there must be a function that can definitely inputting data. Scanf() and printf() can work
together depending on what type of program you are writing. In that case we say the function of scanf()
in c programming is to accept input.
%f : This is called a float. Why it is a float is because it is used as decimal integer unlike %d that is used as
integer without decimal point or decimal places. Examples of %f 1.2, 3.45. 56.4 etc. just and decimal
values of your choice that you can imagine or think off.
Default: Default: is used in a switch-case program when the user pick a value from an option in the
designed or program structure contradictive to it. It will make the compiler to display as error if the user
ick the wrong option.
Switch-case; switch statement is a multi-way branch statement. Using switch-case will allow us
to be able to create multiple choices of program to be executed separately without stressing
the user. So it allows the user to pick options of his/her choice.
Break: The break keyword stops the program flow the switch-case structure and this is mostly found in
loop structures. Specify a break word after a case comparison’s statements so that the rest of the
structures is not executed.
& : We used & so it allows us to pass the address of variable number which is the place of memory
where we store the information that scanf read.
Float: is a shortened term for “floating point”. It is a variable type or variable definition used in
computer program. Simply saying that it is used to define variables. For instance, formulas that have
variables without any fixed number.
\n : This is used for paragraphing. It works with printf() to give the program clarity.
Getch(): This is a function that allows you to end the program. This function is derived from the
#include<conio.h>. without adding #include<conio.h> you can’t use this getch() function to end he
program.