C Tutorials
Variable
Value of the variable can be changed during the execution.
Constant
Value of the constant cannot be changed during the program.
Keyword (or) Reserved word
Keywords have pre-defined meaning which cannot be changed by the user.
Identifier
Names for variables,constants,functions, etc., are Identifiers.
| Data Type |
Size |
| int |
2 bytes |
| char |
1 |
| float |
4 |
| double |
8 |
Type qualifiers:
Variable Declaration:
ex:
int age,tamil,salary;
char gender,name[25];
double temp,average;
Format of C program
#include
main()
{
data type declaration;
stmts;
----
----
}
syntax:
printf("message");
printf("format string with message",variable list);
scanf("format string",address of variables);
format strings(used in printf and scanf):
| %c |
char |
| %d |
int (decimal -base 10) |
| %f |
float |
| %lf |
double |
| %s |
string (combination of characters) |
| %x |
hexa decimal int ( base 16) |
| %o |
octal int ( base 8) |
| %u |
unsigned int |
| %ld |
long int |
| %i |
integer |
|
|