Breaking News

test

Breaking

Post Top Ad

Your Ad Spot

Wednesday, March 4, 2020

What is a Compiler, Data Types and Variables | C++ Tutorials

What is a Compiler, Data Types, Variables:

Today we will discuss what is a compiler, Data Types and Variables

Compiler:

A special program that processes instructions written in a programming language and turns them into “Machine Language” Or “Code” that a computer understands only.
A programmer writes statements or instructions line by line in editor or ide, and the compiler compiles that statements into machine code.

Compiler Example and Variables: 

In simple words compiler is a translater between humans and computers, It converts human information into machine understandable code.

Data Types:


  • A data type tells us what type of data a variable contains. A variable can have an integer data type, character data type or float data type in c++ we have to initialize these variables with data type following are some data types used in c++. 
  • An “int” this data type contains integer value its storage size is 2 to 4 bytes.for example int a=10. A “char”  in char data type contains character value and it stores a single character it takes 1 byte of memory. It contains both lower case and upper case. For example char myname=‘A’. 
  • A “string” a string data type is used when we assign a sequence of characters to a variable. For example string myName= “john”.
  • A “float” this type of data type is used when the integer value comes with a decimal point. Size 4 bytes. It contains 7 digit value. For example, Float a = 23.0000023.

  • A “double” this data type is like float but it contains 15 to 16 digits. Its size is 8 bytes.For example, double = 199.55000012000120.
  • A “bool” in this data type we can store only two values true or false.For example, Bool a = true.
  • A “Const”  is a keyword used with a data type to make the value of variable constant it means that the value of a variable cannot be change. For example Const int a=10.

Data Types Example:
In a real-life example, We can take an example of water, sand and fire. We can store water in a glass type bottle, sand in a cotton bag and fire in an iron box. In this example water, sand and fire can be stored in different types of items.


Variables Example: For this, We can also use the above three items example we used a glass bottle for storing water. Now glass is a type and bottle is a name. But in Computer, We can say the bottle is a variable of type glass.


For More Details about this Topic Watch this Video:



No comments:

Post a Comment

Please comment if you have any queries.

Post Top Ad

Your Ad Spot

Pages