Data Types & variables
Screenshot :
Theory :
Data types are use for declaring variables of different types
Basic datatypes are int,char,float.
Variable Declaration Rules :
1) You should not begin a variable name with a number. They can contain numbers, but you begin it with a letter.
2) Length of variable name should not be greater than 8.
3) The shortest variable name is a letter of the alphabet.
4) Avoid naming your variables the same as C language keywords or functions
5) Don't give similar names to your variables.
Code :
#include<stdio.h>
#include<conio.h>
void main()
{
int i_no=10; //declaration of integer variable
float f_no=1.12; //declaration of float variable
char cha='a'; //declaration of character variable
clrscr();
printf("\n\tInteger Number = %d ",i_no);
printf("\n\tFloat Number = %f",f_no);
printf("\n\tCharacter = %c",cha);
getch();
}
Note : // is use for comment about statement
Here i_no is integer variable,f_no is float variable while cha is character variable
%d is use to print integer variable
%f is use to print float variable
%c is use to print character variable
Output :
0 comments:
Post a Comment