Tutorial references

c
c++
c#

Tutorial references

chapters

data types and range

What is Data Type

It is a keyword.

Data type said, "what type of data a variable can be hold."

Data type said,"what is maximum and minimum range of variable for value."

Types of Data-type

There are three types of data-type in ansi c:

  1. Fundamental Data types(Built-in)
  2. Derived Data types
  3. User define Data types

Fundamental Data types(Built-in)

Syntax:

data-type variableName = value;

OR

data-type variableName;

You can learn bellow fundamental data types.

int

It is a keyword.

1001, 232, 111, 121, etc. is example of int type value.

1001.23, 232.97, 111.00001, 121.99 etc is not int type value.

size of int is 2 byte according to 32-bit operating system.

int type variable hold value between -32768 to 32767

%d is used in printf() function to print int type value.

Example

#include <stdio.h>
#include <conio.h>
void main(){
 int a = 121;
 clrscr();
 printf("value of a = %d",a);
 getch();
}

Run program

%d is used in scanf() function to read int type value.

Example

#include <stdio.h>
#include <conio.h>
void main(){
 int a;
 clrscr();
 printf("Enter value of a: ");
 scanf("%d",&a);/*  & is used before variable name when you want to read data*/
 printf("\n value of a = %d",a);
 getch();
}

Run program

short

It is a keyword.

1001, 232, 111, 121, etc. is example of short type value.

1001.23, 232.97, 111.00001, 121.99 etc is not short type value.

size of short is 2 byte according to 32-bit operating system.

short type variable hold value between -32768 to 32767

%d is used in printf() function to print short type value.

Example

#include <stdio.h>
#include <conio.h>
void main(){
short a = 921;
 clrscr();
 printf("value of a = %d",a);
 getch();
}

Run program

%d is used in scanf() function to read short type value.

Example

#include <stdio.h>
#include <conio.h>
void main(){
 short a;
 clrscr();
 printf("Enter value of a: ");
 scanf("%d",&a);/*  & is used before variable name when you want to read data*/
 printf("\n value of a = %d",a);
 getch();
}

Run program

float

It is a keyword.

1001.23, 232.97, 111.00001, 121.99 etc is example of float type value.

1001, 232, 111, 121, etc. is not example of float type value.But float type variable can hold this type value.

size of float is 4 byte according to 32-bit operating system.

float type variable hold value between -2,147,483,648 to 2,147,483,647

%f is used in printf() function to print flaot type value.

Example

#include <stdio.h>
#include <conio.h>
void main(){
float a = 9833.121;
 clrscr();
 printf("value of a = %f",a);
 getch();
}

Run program

%f is used in scanf() function to read float type value.

Example

#include <stdio.h>
#include <conio.h>
void main(){
 float a;
 clrscr();
 printf("Enter of a: ");
 scanf("%f",&a);/*  & is used before variable name when you want to read data*/
 printf("\n value of a = %f",a);
 getch();
}

Run program

Example

#include <stdio.h>
#include <conio.h>
void main(){
 float a;
 clrscr();
 printf("Enter value of a: ");
 scanf("%f",&a);/*  %.2f is used to print two decimal places. */
 printf("\n value of a = %.2f",a);
 getch();
}

Run program

double

It is a keyword.

1010301.23, 22332.97, 111211.00001, 124961.99 etc is example of double type value.

1001, 232, 111, 121, etc. is not example of double type value.But double type variable can hold this type value.

size of double is 8 byte according to 32-bit operating system.

%lf is used in printf() function to print double type value.

Example

#include <stdio.h>
#include <conio.h>
void main(){
double a = 981933.121;
 clrscr();
 printf("value of a = %lf",a);
 getch();
}

Run program

%lf is used in scanf() function to read double type value.

Example

#include <stdio.h>
#include <conio.h>
void main(){
 double a;
 clrscr();
 printf("Enter value of a: ");
 scanf("%lf",&a);/*  & is used before variable name when you want to read data*/
 printf("\n value of a = %lf",a);
 getch();
}

Run program

Example

#include <stdio.h>
#include <conio.h>
void main(){
 double a;
 clrscr();
 printf("Enter value of a: ");
 scanf("%lf",&a);/*  %.2f is used to print two decimal places. */
 printf("\n value of a = %.2lf",a);
 getch();
}

Run program

Char

It is a keyword.

A character denotes any alphabet, digit or special symbol used to represent information. Following are the valid alphabets, numbers and special symbols allowed in C.

   (1) Alphabets - A, B, ….., Y, Z a, b, ……, y, z

   (2) Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

   (3) Special symbols - ~ ‘ ! @ # % ^ & * ( ) _ - + = | \ { } [ ] : ; " ' < > , . ? /

If you want to use only one character in your program then you can use char data-type.

'A', 'B', 'c', 'M', etc is the example of character.

'1', '5', '9', etc is also the example of char data type but it is not a numeric value.

size of char data type is 1 byte.

%c is used in printf() function to print char type value.

Example

#include <stdio.h>
#include <conio.h>
void main(){
char a = 'M';
 clrscr();
 printf("value of a = %c",a);
 getch();
}

Run program

%c is used in scanf() function to read double type value.

Example

#include <stdio.h>
#include <conio.h>

void main(){
 char a;
 clrscr();
 printf("Enter value of a: ");
 scanf("%c",&a);/*  & is used before variable name when you want to read data*/
 printf("\n value of a = %c",a);
 getch();
}

Run program

Data-type modifiers

It is used to change the base meaning of data type.

(1) signed

(2) unsigned

(3) long

(4) short


About Us

This website(www.sabbla.com) is very useful for beginners and professional developers. Sabbla provides tutorial in simple language. It provides latest technology tutorial which very useful for developers.

See More...

Contact Us

+91 9971366710

+91 9717983128

info@sabbla.com

Buxar, Bihar, India, Pin No.- 802131

Services

Sabbla is providing free latest technology tutorials. All tutorials are free for beginner and professionals.


Terms of Use

sabbla.com is not responsible for any mistake. Users can inform to sabbla.com for any mistake. But sabbla.com always try for 0-0 mistake.

Privacy policy

Currently sabbla.com does not collect any data from users.

                   

copyright © 2017-2018