CodersEditor Tutorials

CodersEditor Tutorials

  • Online IDE
  • Q&A
  • C Programming
  • Java
  • GraphQL.NET
  • System Software

›Introduction

C Programming

    Introduction

    • Overview
    • Installation & Setup
    • C Program Structure
    • Keywords & Identifiers
    • Data Types
    • Variables & Constants
    • Scope Rules
    • Storage Class
    • Standard Input and Output
    • Operators

    Control Flow/Decision Making

    • Overview
    • if Statement
    • if else Statement
    • Nested If statement
    • Switch Statement
    • Nested Switch Statement
    • Conditional Operators

    Loop

    • Loops Overview
    • While loop
    • For Loop
    • Do while
    • Nested Loops
    • Break
    • Continue Statement
    • Goto statement

    Arrays

    • Arrays
    • Multi Dimensional Arrays
    • Arrays & Functions

    Pointers

    • Pointers Basics
    • Pointers and Arrays
    • Pointers and Functions
    • Memory allocation

    Strings

    • String Basics
    • String Functions

    C Programming Examples

    • Basic Example 1

C Programming Data Types

In this article, you will learn what is a datatype and some basic datatypes used in C programming.

Datatypes - Introduction

Datatypes are the declarations for variables. This determines the type of data and also the size of data associated with variables.

Data types specify what type of data we enter in a program. All the variables used in a C program must be declared with a datatype.

Datatypes in C are classified into

Primary datatypes

Primary datatypes are fundamental datatypes in C. They are integer, floating point, double float, character and void.

Data types and its key words:

  • Integer int
  • Character char
  • Floating point float
  • Double float double-

Derived datatypes

Derived datatypes are primary datatypes that are twisted or grouped together like an array, pointer,** structure** and union.

Some of the basic datatypes and their characteristics are described below.

Integer (int)

The datatype Integer holds the whole number. Example: int marks; Here, In marks, you can only store a value that is the whole number.

Floating point(float)

This is used to store the decimal number with single precision. Example: float percentage; This allows you to store value with decimal places.

Double(double)

This is used to store the decimal number with double precision.

Example: double average;

Character(char) It stores a single character and uses only a single byte of memory.

Example: char answer = ‘T’;

Sample Program

    #include <stdio.h>
    #include <limits.h>
    int main()
    {
       int a=57;
       char b = 'H';
       float c = 57.57;
       double d = 123.456789;
       printf("Hey am an integer and my value is:%d \n",a);
       printf("Hey am a character and my value is:%c \n",b);
       printf("Hey am float and I hold %f as my value. \n",c);
       printf("Hey am double data and I hold %d as my value. \n ",d);
       return 0;
    }

Output

Hey am an integer and my value is:57                                                                                                          
Hey am a character and my value is:H                                                                                                          
Hey am float and I hold 57.570000 as my value.  
Hey am double data and I hold 2147483614 as my value.
← Keywords & IdentifiersVariables & Constants →
  • Datatypes - Introduction
    • Primary datatypes
    • Data types and its key words:
    • Derived datatypes
    • Integer (int)
    • Floating point(float)
    • Double(double)
CodersEditor Tutorials
CoderdEditor Developer Tools
CodersEditor Online EditorGit Flavoured Markup EditorFree Online JSON FormatterFind My IP Address Details
Tutorials
C ProgrammingJava
Copyright © 2021 CodersEditor.com