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
write a programme that allows a user to enter 5 distinct words and returns them as a single string

how to create a shopping cart

Example for Register Storage Class - computer programming? main() { register int i; for (i=0; i { ............... ............... } } /* block exit will free the register

write a program that counts the number of occurrences of the string in the n-th Padovan string P(n)   program in java // aakash , suraj , prem sasi kumar kamaraj college

Explain what are Unions? The Unions like as structures, contain members whose individual data types may perhaps differ from one another. Though the members that create a union

Explain the different types of errors in PHP. Warnings, Notices and Fatal errors are the types of errors in PHP Notices: Notices signifies non-critical errors, i.e. ac

B-tree: A B-tree is an also called balanced m-way tree. A node of the tree may have many records or key and pointers to children. It is also called as the balanced sort tree. It s

A: #include // Test to see if pointer hopping is worthwhile. // strlen implemented with usual indexing mechanism. int strlen1( const char str[ ] ) { int i; for( i =

Command-line arguments are passed into programs using the arguments of main(). Here's a quick example, for a program called by typing "progname file.txt 1 2.7": #include #incl

THEORY OF COMPUTER PROGRAMMING