Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

what is data type

+53 votes
asked Feb 6 by himanshu kumar (230 points)

7 Answers

+2 votes
answered Feb 6 by Peter Minarik (86,240 points)
edited Feb 8 by Peter Minarik

Data type tells you what sort of information is stored in your variable. I'll use C language examples below. Every language has its own data types, but the basic data types are very similar across languages.

Let's assume you would like to store some kind of a number, let's say, someone's age. You could store it in an int data type, that represents integral numbers. This data type can only handle whole numbers, no fractions.

If you'd like to store someone's salary, you'd probably use a floating point data type, so fractions could be used. Such a type would be float or double.

If you'd like to store a name, then you would use a string that can store text. In C, you can store a string in a char * data type.

You can also create your own data types as structures (or classes in object-oriented languages).

Here's an example below:

#include <stdio.h>

typedef struct
{
    char * name;
    int age;
    float salary;
} Employee;

int main()
{
    Employee employeeOfTheMonth = { "Joe Smith", 32, 67458.95 };
    printf("Employee of the month is called %s.\n", employeeOfTheMonth.name);
    printf("Employee of the month is %d years old.\n", employeeOfTheMonth.age);
    printf("Employee of the month earns $%.2f.\n", employeeOfTheMonth.salary);

    return 0;
}
+2 votes
answered Feb 19 by Elavarasan Mohan (180 points)
Data Type:

In the C programming language, Data types tells to the compiler what kind of data's we are going to use in our program. Generally , in the C programming language data types are classified into four categories , these are 1.Basic data type  2. Derived data type 3. User defined data type 4. void data type.

1) Basic data types: coming to the basic data types has different types based on data's. these are

Int data type - Its described about integer's value  (Eg: 1,2,3,....456....n)

char data type - its described about characters (Eg; a,A,b,B....z,Z)

float data type - its described about floating point numbers (Eg: 1.1,2.2,3.3.....n.n)

double data type - its also described floating point number but after point it can consider 2 digits (Eg:1.11,2.22..n.nn)

2) Derived data types

Array , functions , pointers , reference these are all the derived data types.

3) user-defined data types :

structure, union, enumeration, typedef these are all the user defined data types.

4) void data types

it is associated with zero which means void means nothing .

These are all the different data types in the c programming language. these data types used to we can declare the data , define the data and initialize the data in the c programming language .

C programming compilers only understand or identified through the data types what type of data's we are used in our program.

Note: one more thing , these data types reserved words in the c programming language because the data types has specific roles in the c programming language . so, these type data types we cant able to use another roles. If we are try to use we will get compiler error.
+1 vote
answered Feb 23 by PRATHEEP PARAMASIVAM DCGP (160 points)
There are different types of data, In the world every information is the data.

In the programing the data are three major types Number, Characters

Number is classified into two types integer (Positive and negatives of whole numbers ) and float (Pointing integers)
Characters (Char) which include the special characters, alphabets and numbers
+1 vote
answered Mar 5 by Monish Wadile (160 points)

In software programming, data type refers to the type of value a variable has and what type of mathematical, relational or logical operations can be applied without causing an error. For example, many programming languages use the data type string to classify text, integer to identify whole numbers and floating point to designate numbers with decimal points.

+1 vote
answered Mar 10 by Eidnoxon (5,140 points)
Dang. This is like the most liked post on this forum. Good luck on your programming journey!
commented Mar 14 by Larissa (180 points)
obrigada><
lindo
sou muito pequenininha pedro
0 votes
answered Mar 12 by Mehul Agrawal (130 points)
SAB BAKWAS HA KOI DAM WALI BAT NHI HA
commented Mar 14 by Larissa (180 points)
concordo lindo
0 votes
answered Mar 14 by Srishith Patel (140 points)

Data type is something where the value , variables are stored. There are different tyoes of data types :

  1. Integer: Used to store whole numbers without decimal points, such as 1, 10, -5, etc.
  2. Floating-point: Used to store numbers with decimal points, such as 3.14, -0.5, 2.71828, etc.
  3. Character: Used to store single characters, such as 'a', 'X', '%', etc.
  4. String: Used to store a sequence of characters, such as "Hello", "World", "12345", etc.
  5. Boolean: Used to store either true or false values.
  6. Array: Used to store a collection of elements of the same data type.
  7. Structures/Objects: Used to group different types of data under one name.
  8. Pointer: Used to store memory addresses.
  9. Enumerations (Enums): Used to define a set of named integer constants.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...