C Data Types
C Programming

C Data Types

 

In C programming, data types specify an extensive system used for declaring variables(like int a) or functions(void fun1()) of different types. The C data type of a variable determines how much space it occupies in memory and how the bit pattern stored in memory will be understood by the processor.
Various arithmetic datatypes and functional data types available in the C programming language are enlisted below


Data Types in C and Description

Basic data types Of C language:

integer type

This type is used to define integer numbers. It is denoted as “int” in the C programs in this c programming tutorial
{
int number;
number = 5;
}

Floating-point types.

This type is used to define decimal numbers. It will be denoted as “float” in the c language

{
float Miles;
Miles = 5.6;
}

Boolean type

The Boolean type is used to define a variable that consists of only two values true or false
{

bool b = getc(stdin) == ‘t’ ? true : false;

}

double – data type

Double in c language is used to define BIG decimal point numbers. The memory reserved for this datatype is twice as compared to the int datatype. Likely to be 8 bytes.

{
double Atoms;
Atoms = 2500000;
}

char – data type


char data type defines characters in a c program.

{
char alphabet;
alphabet = ‘x’;
}

Example(data types)

#include<stdio.h>

#include<conio.h>

void main()

{

int a=2;

float b=6.78;

char c=’x’;

double d=456.678;

clrscr();

printf(“integer=%d”,a);

printf(“\nfloat=%lf”,b);

printf(“\nchar=%c”,c);

printf(“\ndouble=%lf”,d);

getch();

}

Data types in C

Enumerated types in C language:

They are also arithmetic types and they are used to define variables that can only be assigned certain discrete integer values throughout the c program.

The type void:

The type specified void returns no value, meaning no value is available. It is used mainly in functions that return null or no value.

Derived types in C programming:


They include (a) Pointer types(int *a), (b) Array types(int a[5]), (c) Structure types(struct student), (d) Union types, and (e) Function types(void or int).

Example(derived data type)

#include<stdio.h>

void main()

{

int *x[3];

int a=10, b=15, c=20,i;

clrscr();

x[0]=&a;

x[1]=&b;

x[2]=&c;

for(i=0;i<3;i++)

{

printf(“address=%u\t”,x[i]);

printf(“value=%d\n”,*x[i]);

}

getch();

}

Derived Data type in C

Recommended Posts

C++ Programming

Visibility modes in C++

In C++, visibility modes refer to the accessibility of class members (such as variables and functions) from different parts of a program. C++ provides three visibility modes: public, private, and protected. These modes control the access levels of class members concerning the outside world and derived classes. Public: Members declared as public are accessible from […]

Rekha Setia 
C++ Programming

Inheritance in C++

In C++, inheritance is a fundamental concept of object-oriented programming (OOP) that allows you to create a new class based on an existing class, known as the base or parent class. The new class is called the derived or child class. Inheritance facilitates code reuse and supports the creation of a hierarchy of classes. There […]

Rekha Setia 
C++ Programming

C++ Classes and Objects

In C++, classes and objects are fundamental concepts that support object-oriented programming (OOP). Here’s a brief overview of classes and objects in C++: Classes: In C++, a class is a user-defined data type that allows you to encapsulate data members and member functions into a single unit. Classes are the building blocks of object-oriented programming […]

Rekha Setia 

Leave A Comment