C Programming

C programming Tutorials: Part – 03

Written by Saiful Islam

Previous parts :

C programming tutorials: part 1

C programming tutorials: part 2

In the previous part I showed you the procedure of making a variable name. Today I will show you how to use.

Usage of different variables

There are three kinds of variables :

1. Float variables :

This type of variables proceeds only ” float ” types of variables. We use ” %f ” to execute input (through “scanf “function ) and output (through “printf” function).

Ex :

3.01 , 10.056, 11.985, 13.131 etc.

2. Integer Variables:

This type of variables proceeds only “integer” types of variables. We use ” %d ” to execute input (through “scanf “function ) and output (through “printf” function).

Ex :

3, 10, 11, 13 etc.

3. Character variables:

This type of variables proceeds only “character” types of variables. We use ” %c” to execute input (through “scanf “function ) and output (through “printf” function).

Ex :

A, D , G, Z etc.

Ok. Now friends,

Look at the following program:

[Warning: Don’t copy paste the program (copy paste doesn’t work) just type the program on your compiler. ]

Description:

  1. Here ”┬áTech-posts “ is used as a variable name. I have used ” int”(the short name of the integer) because the number of posts can’t be either character or float variables.
  2. I (not user) have given an input which is ” 5 “.
  3. You can see that there is a “printf” function has been used to show the output.
  4. I have used “%d” before “posts” to ensure the perfect placement of the output ( 5 ).
  5. “Tech-posts” has been used into ” printf ” function to get the input from “Tech-posts” and show it to viewers.

Output of the program:

 

About the author

Saiful Islam

Leave a Comment