4.Data type in c language | C Tutorials for beginers #4

4.Data type in c language | C Tutorials for beginers #4

https://harshaup.blogspot.com/2021/05/4data-type-in-c-language-c-tutorials.html?m=1

Data Type in C Programming

ans: Type of data is know as Data type. int,float,char are example of data type in c

Types of  Data Type in C Programming

1.primary data type

2.Derived data type.

Primary data types

Integer(int),floating(float),character(char),void are the primary data type

Derived data types

 arrays, functions, stuctures and pointers are Derived data types.


Integer type

Integers are used to store whole numbers.

Size and range of Integer type on 16-bit machine

TypeSize(bytes)Range
int or signed int2-32,768 to 32767
unsigned int20 to 65535
short int or signed short int1-128 to 127
long int or signed long int4-2,147,483,648 to 2,147,483,647
unsigned long int40 to 4,294,967,295

Floating type

Floating types are used to store real numbers.

Size and range of Integer type on 16-bit machine

TypeSize(bytes)Range
Float43.4E-38 to 3.4E+38
double81.7E-308 to 1.7E+308
long double103.4E-4932 to 1.1E+4932

Character type

Character types are used to store characters value.

Size and range of Integer type on 16-bit machine

TypeSize(bytes)Range
char or signed char1-128 to 127
unsigned char10 to 255

void type

void type means no value. This is usually used to specify the type of functions.


Typecasting in C Programming

ans: Conversion of one data type to another is known as typecasting.

1.Explicit typecasting.

2.Implicit typecasting.

Explicit Typecasting

Those type of type casting which is done by the programmer by posing the data type.

for example:

#include <stdio.h>
 void main () {
   int sum=17,div=6;
   float value;
   value=(float)sum/div;
   printf("value is %d",value);
  
  output:value is 2.833333
   

Implicit Typecasting

Those type of type casting which is done by the compiler automatically.


No comments

Comments system

Powered by Blogger.