fb popup

/* remove if it's exist in your template */

Basic Things to Know

"If there are any images please click on them to get a clear picture of that"

Identifiers:-These are the variables that represent arrays, value etc. Ex:- int a=5; float b=7; double c[2]={2,3}; here a,b,c are called as variables or identifiers.  

There are certain rules we should follow to use a variable in our program:
  1. It can have numbers,digits.
  2. Should not contain spaces between 2 words but we can append them using underscore. Ex:-Hello_world.......correct way. Hello world........wrong way.
  3. Never start with a digit.
  4. They are case sensitive which means A and a are not same. Ex:- int HeLLo_World=256; int Hello_World=341; So if we print HeLLo_World then the output is 256 and if we print Hello_World then the output is 341.
Why is this so?
  It is because we know that both give same meaning but compilers are not having natural intelligence like us.They will take as input what ever we give to them.They don't see the meaning of a variable. so,that is why it consider both of them as differently.When ever we declare variables we should think from the side of compiler.



In every program we use data types.

 Data types are of 3 types:-
 1.User defined data types such as structures,functions etc.
 2.Built in data types such as int,float,char,double etc.
 3.Derived datatypes such as arrays and pointers

 1.int :-represents integer type i.e if we declare as Ex:-int a then a should contain only integer values.

2.float:-represents decimal values. Ex:- float a means a can take values containing decimals.As float a=7.777;

 3.double:-the variable here can be an integer containing more range than int or can be of a float type. Ex:- double a; 4.char:-represents character Ex:-char a='A'; if it is a single letter we represent the letter with in single quotes. char a[]="hello" if it is more than one letter then we represent the word with in double quotes. For each data type there are range of values. Ex:-considering a 16 bit compiler int has 2 bytes which means from -32768 to 32767. that is if we declare int a=43555 and printing value of a gives us a garbage value. similarly for every data type they have their range values.  

The different data types are as follows:-
Data Types
 in normal case we use mainly int,float,double, and char. If we use 'char' while printing we should use %c if it is a character in single quotes otherwise %s if it is a word in double quotes.

 letter in single quotes are called as characters and those in double quotes they are called as strings.
 Ex:-

Charcter Example

                     here I used "\n". It is for going to next line.
output:-

Charcter Example Output




Escape sequences:-

\n--new line.

\t--a space of tab width.

\v--vertical tab.
As in the above program we used \n so the output statements are in line by line otherwise the output will be like:-

Charcter Example without escape sequence


  output:- 

Charcter Example without escape sequence Output

No comments:

Post a Comment