Home / Tutorial / Programming / C / C ++ Programming Tutorial (Part 9) Functions and Loops
c programming tutorial

C / C ++ Programming Tutorial (Part 9) Functions and Loops

The main theme of today’s episode is to shorten the function and the loop, but it’s about the operator and the expression.

Some characters on the keyboard include: +, -, *, /,>, <, = etc are used to perform mathematical, logical, or related tasks or to control such tasks. Operator of such type of characters. Expressions are created by executing operators, constants and variables in the program correctly. Such as: int a, b = 10; a = b; Here the two variables a and b are declared in the first line, where n is set to 10. The value of the n in the second line is set to false. Here the second line is an expression.

Operators can be divided into several categories. However, those used in C are most commonly used:
• Arithmetic Operators: +, -, (multiplication), / (share),% (modulus or fraction).
• Relational operators:>, <,> =, <=,! = (Not equal), == (equal)
• Logical operators:! (Not), && (and), .. (or)


The semicolon (;) is used to denote the end of a line in C. When a compression expression is ended with a semicolon, then in C, he is called a statement. The statement usually consists of two types:

Simple statement: The statement that consists of a single expression or function is a simple statement.
Compound statement / code block: When multiple statements are written in the second bracket ‘{}’, they are called compound statements or code blocks. There is no special difference between the simple and compound statements, only the scope or workspace is different.


To use the loop in the loop, if else, for, while, do while etc are used.
The rave else statement can be used in three ways. For example: if if, if and else, else if chains For example, three small programs are given:
Only if
if (age> = 18)
printf (” you are mature. ”);
if (age <= 18)
printf (” You are immature. ”)
else if
If (age> = 18)
printf (” you are mature. ”);
printf (ÒYou are immature. ”)
else if the chain
if (age> = 50)
printf (” you are old. ”);
else if ((age> = 25) & (age <50))
printf (” you are young ”);
else if ((age> = 18) & (age <25))
printf (” you are mature ”);
else if ((age> = 10) & (age <18))
printf (” you are a boy ”);
else if ((age <10) & (age> 0))
printf (” you are a child ”);
printf (” you are not born !! ”);
Noteworthy, Els If Chain starts with Eiffel, inside Els If and the end is only Els.
There is a condition in the beginning of the latex loop, then there is a code inside the code box. Such as:
int x = 1;
while (x! = 100)
printf (”% d ”, x);
x ++;

The function of the Fur while loop is similar to the Youtube loop, the only difference is that in the beginning of the year, the Yesterbut checks the condition, then enter the code block. And in the Fur while loop, the condition will be checked at first once the code block runs. Such as:
printf (” press any key to print and ‘q’ to quit: \ n “”)
char ch;
ch = getch ();
printf (”% c \ n ”, ch);
} while (ch! = ‘q’)
For loop use is the most. It’s easy to use rules too. Such as:
int i = 0;
for (i = 0; i <10; i ++)
printf (”% d \ n ”, i);


When writing the code in C. Everyone writes this section (main), which needs to be written. This is a function, called the main function. Apart from this, such programs can not be run, there are many more functions that reduce the complexity of the program in multiplication. Their work is the same and used to do the same type of work at different times. There are different functions in printf (), scanf (), clrscr () etc. in C. The functions of these functions are the same. As such, printf () – printed in some print, that is displayed in the monitor, scanf () – is the work of the keyboard to take any input from the user, clrscr () works on the screen, all that is deleted etc. These tasks are not so easy, for example, in order to take input, many codes need to be written in C. But, just writing scanf () can take input easily, because the code for it has been written beforehand This scanf () function is written in the header file named stdio.h. When scanf () is written in the program, the program compiles the code associated with the corresponding header files. Thus, the function of the function is to complete the entire program step by step.
Function is basically two types: library functions and user defined functions. Another function of the library function is the builtin function. The functions that are mentioned in the header file are Library Functions. Such namesake is seen to have already been written in these functions. According to the compiler, the function of the libraries is determined. However, most functions remain unchanged in all compilers. There are also many external library functions available on the internet. It is possible to run the program more easily by using them. Another function name is User Defined Function. There is no such difference between them. The library functions are those that are mentioned earlier. And the user defined functions are the functions that the user makes for their convenience. An example of a user defining function is given below:
void func ();
void main ()
clrscr ();
func ();
void func ()
printf (” a user defined function is created ”);


Arrays are a method of declaring several variables together. Suppose, there is a need to declare five variables in a program simultaneously. Then the user can declare five variables in common rules. You need to write five statements for this. But using the array, it is possible to declare five variables at the same time, ie, with a statement. It may not be so important for only five variables, but if you need to declare 100 or 1000 variables simultaneously in big programs, then using coding makes coding easier. The array declares the same as the variable declaration. For example: int prime [10], valid [5]; Etc.


Pointer is a special variable, but it can not contain any common values. It can only contain addresses of other variables. The address is the main subject for a program. Each variable has an address. The program knows those variables not by their name, but their address. If you change anything in that address, then the changes will be seen in the relevant variables. That is, if the address of a variable is deleted, then the value of the address will be deleted if the value of the address is deleted. Again, assigning a new value to an address will change the value of the variable that is in the address.

About Admin

Leave a Reply

Your email address will not be published. Required fields are marked *