Skip to main content

Data type

 

What is Data Type?


A Data Type is something which describe about data nature. Data type tells the program that which type of value a Variable will hold and what type of mathematical, relational and logical operation can be performed on that variable without getting any error. If variable int x = 45, that means, 45 is integer value which is being kept in variable x and we could do mathematical operation on it.

There are basically 5 types of data types, when we are talking about c language.

Int, Float, Double, Long, char, Boolean, String, etc.

Few data types which we use often in c language is below:-

Int - Int defines as Integers. In int we can hold any numeric value. It occupies 4 bytes of memory. Keyword used for Integers value is int.

Float – Float defines as floating point number. It means we can hold any decimal number in it. It also occupies 4 bytes of memory. Keyword used for Float point values is float.

Double - Double data type is used for storing double precision floating point values or simply decimal values. Keyword used for double floating point data type is double. Double variables typically require 8 byte of memory space.

Long – Long also holds the integers value. It occupies 8 bytes of memory. Keyword used for Long is long. It is basically use when you have large number to store in variable.

Character – Character data type hold the alphabet or any character value in it. Keyword used of Character is char. Character requires 1 bytes of memory space.

Comments

Popular posts from this blog

Day 2: Conditional Statements: Switch

  Objective In this challenge, we learn about  switch statements . Check out the attached tutorial for more details. Task Complete the  getLetter(s)  function in the editor. It has one parameter: a string,  , consisting of lowercase English alphabetic letters (i.e.,  a  through  z ). It must return  A ,  B ,  C , or  D  depending on the following criteria: If the first character in string   is in the set  , then return  A . If the first character in string   is in the set  , then return  B . If the first character in string   is in the set  , then return  C . If the first character in string   is in the set  , then return  D . Hint:  You can get the letter at some index   in   using the syntax  s[i]  or  s.charAt(i) . Input Format Stub code in the editor reads a single string denoting   from ...

Day 2: Conditional Statements: If-Else

Day 2: Conditional Statements: If-Else || Hackerrank Solution Objective In this challenge, we learn about  if-else  statements. Check out the attached tutorial for more details. Task Complete the  getGrade(score)  function in the editor. It has one parameter: an integer,  , denoting the number of points Julia earned on an exam. It must return the letter corresponding to her   according to the following rules: If  , then  . If  , then  . If  , then  . If  , then  . If  , then  . If  , then  .

Jumping on the Clouds Hackerrank

Jumping on the Clouds solutions in c. Emma is playing a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. She can jump on any cumulus cloud having a number that is equal to the number of the current cloud plus 1  or 2  . She must avoid the thunderheads. Determine the minimum number of jumps it will take Emma to jump from her starting position to the last cloud. It is always possible to win the game. For each game, Emma will get an array of clouds numbered 0   if they are safe or 1 if they must be avoided. For example, c=[0,1,0,0,0,1,0] indexed from 0....6. The number on each cloud is its index in the list so she must avoid the clouds at indexes 1 and 5 . She could follow the following two paths:0 ➜ 2 ➜ 4➜6   or 0 ➜ 2 ➜ 3 ➜ 4 ➜ 6 . The first path takes 3   jumps while the second takes 4 . Function Description Complete the  jumpingOnClouds ...