Primary data type in cpp, C/C++ Programming

What are Primary Data Types?

Integer can be defined according to the size of the data and it can be modified further by using keyword unsigned and signed.  Default declaration is signed; that is a variable can store negative and positive data, to hole only positive data the variable can be changed to unsigned variable which will store only positive data twice its original size.  Therefore the size of the data to be stored in a variable depends on type of declaration.

int x:  The x store from -32768 to 32767 since by default it is a signed integer it can store positive and negative number within that range.

unsigned int x:  The x store from 0 to 65535 since it is declared as signed integer it can store only positive number within that range.

The data type can be declared unsigned for long, char,  small int, and int only.  The double and float can be signed data only.

Void data type is used to declare a generic pointer. 

void *gptr;

 

int *ptr;

gptr = ptr;

char *cptr

cptr = gptr;

Valid only in C

cptr = (char *)gptr;  In C++ type casting operator must be used to change the data type.

Note: In C void pointer can be assigned to non-void pointer without using cast. Where as in C++ cast operator must be used to assign void pointer to non-void pointer. 

Integer data types are of three types; octal, hexadecimal and decimal int x = 123; is decimal data type

int x = 0123; is octal data type int x = 0x12A; is hexadecimal

The primary data type like long, integer

 

Posted Date: 9/20/2012 7:30:31 AM | Location : United States







Related Discussions:- Primary data type in cpp, Assignment Help, Ask Question on Primary data type in cpp, Get Answer, Expert's Help, Primary data type in cpp Discussions

Write discussion on Primary data type in cpp
Your posts are moderated
Related Questions
- Create a program that uses at least two functions that will be called from your main. This program is a number game program that asks for parts of your phone and after manipulati

Explain the class invariant. - It's a condition that ensures correct working of a class and defines all the valid states for an object. - When an object is created class inv

Ba s i c r u l e s o f C + + p r o g r a m : ·     I t m u s t h a v e o n l y o n e m a i n f u n c ti o n ·

Why PHP is also known as scripting language? PHP is fundamentally a general purpose language, which is used to write scripts. Scripts are normal computer files which comprises

assume that the first integer read with cin specifies the number of values remaining to be entered. that program should read only one value each time cin is executed .a typical inp

Explain string constants in c language - Escape Sequences? Illustrations are "945", "hello", "well done", "5+3". The character constant (example 'x') isn't equivalent to the st

Rule: To determine the canonical form we should OR the min terms. A min term is defined as a Boolean equation of the input if the output is logic '1'. If the input is logic '1'

Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

Add words in Dictionary: void Dictionary::add( Object& objectToAdd ) {     if( !objectToAdd.isAssociation() )         ClassLib_error( __ENOTASSOC );     else