Learn Computer Programming - Level one of C Programming (Part 03)
In this part there is level one about C programming
In previous post we discuss about the starting level of C programming, Today we are going to discuss about some more of C programming and the basic need for composing C program. So let's start
In C programming programmer use comment system to understand which program they need to type or which program they type bellow. Comment is very important when you are working on a large program. It's also help to make solution of various problem. By showing the comment programmer can make decision where what program need to change for updating any feature of the program. It is not part of the program. It's just help to remember you. But how to write comment during programming on a compiler. That we discuss bellow.
You can start wring comment after /* and finished it before */. This is called the comments of programming languages. You can write almost anything in plain text in comment.
When you compile the line, we will see that "we will print now" the line will not be output.
To understand the conversion, you must understand about the strings. In a word, string is the sum of the characters or words. A conversion character is a type of play order that place command in a string. We will now see a program using Conversion Character.
By this line we understand any of word or person is a good boy. Now we will see the using of it on a active program :
Now the output is : Rahim is a good boy. That's mean %s is replace by the name Rahim. But if there is two of %s then what happen, let's see :
And now the output will be : Rahim is a good boy I have ever seen, the second %s replace by I have ever seen. There is one thing you have to know that the %s is only for the string such as word or text. But it's also possible that you are using number in programming but to do so follow the bellow coding.....
Then the output will be : Bangladesh won by 67 runs. %d is used for integer. But if you used decimal in it, it will show it error. If you want to use decimal then use %f on program.
Then the output comes : My result on exam is 4.50 point.
Data types are required according to data values for variables declaration. The four types of data type are basically.
char :To work with character type or alphabet in C programming, char is used to type char data type for variable declaration. The char keyword is used to declare variables of char type.
Eg: char ch;
int : An int data type is used to declare an int type variable to work with the integer number. int keyword is used to declare variable type int.
Eg: int x;
float : float data type is used to declare variable type to work with decimal numbers. Float type is used to declare variable type of float.
Eg: float y;
double : We use the double data type variable to declare variable to work with a large number of decimal numbers. double keyword is used for double type variable declaration.
Eg: double z;
Data type Declare
Data declaration refers to declaring variables in certain data types. Variable declaration format of a data type is
Example: Char ch; int x;
Variable refers to the name or address of the location of memory. When working with data in the program, we have to use a variable for each data. In other words, it is possible to keep only one data at any time in any variable. There are five types of variables used in C language.
- Numeric variable
- Array variable
- Pointer variable
- String variable
- Custom Variable.
To work with any data in the program, first to declare the variable with the data type; for the C program, all the variables at the beginning of the main () or other functions; It has to declare data type.
However, it is to be remembered that two or more variables can not be declared in the same function.
Example of Variable Declaration
Now a integer number for ages and a decimal can be used for marks.
age = 25;
marks = 23.8;
See the program below: