Latest Post
Showing posts with label Variables And DataTypes. Show all posts
Showing posts with label Variables And DataTypes. Show all posts

Fundamental Data Type - Double Type Variable

Written By Unknown on Monday, October 7, 2013 | 11:58 AM

Double Type Variable :

Double type variable is as like float type variable.8 byte memory will be allowed for double type variable.The highest value for double type variable is 1.7*10^+308 and the lowest value is 1.7*10^-308.

Watch The Program Carefully :

#include<stdio.h>
#include<conio.h>
main()
{
double dl;
clrscr();
dl=123.12;
printf("Value of dl is %e",dl);
dl=1234.12;
printf("\n Value of dl is %e",dl);
getch();
}

OUTPUT : 

Value of dl is 1.231200e+02
Value of dl is 1.234120e+03

Fundamental Data Type - Character Type Variable

Character Type Variable :
We use character in C - Program to declare the variable as a character type variable.If we declare any variable as a character then C Compiler allow 1 byte memory for that variable.

EX :  Char ch;

here ch is declared as a character type variable and ch will get 1 byte memory.The highest value of character type variable is +127 and the lowest value is -128 according to ASCII.

Watch the program carefully :

#include<stdio.h>
#include<conio.h>
main()
{
char ch1,ch2;
clrscr();
ch1='1';
ch2=1;
printf("ch1 is %c",ch1);
printf("\n ch2 is %c",ch2);
getch();
}

OUTPUT :

ch1 is 1
ch2 is 1

Program Analysis :

->char ch1,ch2;
here ch1and ch2 is two individual character type variable,

->ch1='1'
If we need to keep a character into a character type variable then we must keep it into a single quote ( ' ' )
-> %c
If we need to print any character type variable on our computer screen then we must use %c

Fundamental Data Type - Float Type Variable

Written By Unknown on Sunday, October 6, 2013 | 8:03 AM

Float Data Type :
Float data type represent floating - point number like a number containing a decimal point or exponent.If we need to work with 20.02 we must put it in a float type variable.

Compiler keep 4 byte memory for a float type variable.The highest value for a float type variable is 3.4*10^38 and the lowest value is 3.4*10^-38

Watch the program Carefully :

1.#include<stdio.h>
2.#include<conio.h>
3.main()
4.{
5.float fl;
6.fl=1.0000000000                         -> 10 "0"
7.printf("The value of fl is %f",fl);
8.getch();
9.}


OUTPUT :

The value of fl is 1.000000            -> 6 "0"



Program Analysis :

-> Here fl is announced as a float type variable.

-> As fl = 1.0000000000,so the value of fl is fixed

-> In printf we saw %f.It stands for showing the float number value on the computer screen as like %d shows int value.

-> In the output we can see six 0 after decimal because float type variable don't keep more than six digit after decimal.



Fundamental Data Type - int (Integer)

Integer Data Type :
Integer is the first Fundamental Data Types among the four.Integer means whole numbers like 1,5,10,345,1257 etc.The short form of Integer is "int". int type variable is use to express whole numbers in C - Program.It takes 2 byte( 16 bit ) memory in a C - Compiler.

Ex : int i;

Here i is announced as an int type variable.The highest value for an int type variable is
+32767 and the lowest is -32768

Watch the program carefully :

1.#include<stdio.h>
2.#include<conio.h>
3.main()
4.{
5.int i;
6.i=32767;
7.printf("The value of i is %d",i);
8.i=42787;
9.printf("\nNew valu of i is %d",i);
10.getch();
11.}


OUTPUT :

The value of i is 32767
New value of i is -22876

Program Analysis :
As "i" is declared as an int type variable so the highest value of i is 32767 and it is printed in our computer screen as exact but when we put the value of i higher than it can contain so the error occurred and the second value of i is irrelevant.

So we must be conscious when ever we need to work with int type variable and we also keep in our mind the highest and the lowest value of an Integer Type Data.  


Definition And Rules To Write Variables

Definition : A variable is an identifier that represent a single data item like a numerical quantity or a character constant.Watch the program below :

1.#include<stdio.h>
2.#include<conio.h>
3.main()
4.{
5.int a,b,c;
6.char d;


In this program a,b and c are integer type variables and d is a character type variable.So we can easily say a,b and c will represent an integer valued quantity and d will represent a single character.


Rules To Write Variables : A programmer can use a variable name as the way he or she want but it should maintain the format mentioned below :

1. Programmer can use the mixed value of upper case alphabet ( A........Z ),Lower case alphabet ( a......z ) or Underscore ( _ ) to write a variable.

2.Variable name must start with an alphabet like ( A.....Z ) or ( a....z ).Some compiler also support underscore( _ ) first.

3.According to ANSI a variable name could contain up to 31 Character.

4.We can not use C-Keyword as a variable name.

5.Uppercase ( A.....Z ) and Lowercase ( a.....z ) are different in "C" so here "Sum" and "sum" are two different variable.

6.We can't place any "White Space" in a variable name like "SHU VO".It wll be "SHUVO"


Examples : 

Valid Variable Names :
                                       1.Shuvo
                                       2.S11
                                       3.SHAKHAWAT
                                       4.A_H_A_M_E_D

Invalid Variable Names:
                                      1.sh uvo
                                      2.0 43
                                      3.[ABC]
                                      4.(Ahamed)
                                      5.%S
                                      6.#shakhawat#

NOTE : 
Some character we can't use as a variable name like #, (, {, [ etc.

CONFUSE??

CONFUSE??
 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Learn Programming - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger| Distributed by Rocking Templates