types of constants...

2 views
Skip to first unread message

Neha

unread,
Mar 1, 2011, 12:32:55 PM3/1/11
to Knowledge Test
how many types of constants are there in C language?

akanksha shukla

unread,
Mar 1, 2011, 1:56:30 PM3/1/11
to knowledge-...@googlegroups.com
I think
primary toh 3 hote hai ---- int float char
secondary - array structure union enum
wats d actual ans?
Message has been deleted

TheSuyog

unread,
Mar 2, 2011, 3:47:52 AM3/2/11
to Knowledge Test
int, float & char and array, struct, union & enum are primary and
secondary "data types" respectively not constants.

Types of constants are:

1. Integer constants: ordinary integer numbers including decimal
(1234), octal and hexadecimal (0x1234) representations,

2. Floating point constants,

3. Character constants,

4. String constants: actually arrays of characters ("Hello").

These are actually the literal values that we assign to a variable.
Ex.: int a = 123; here int is data type, a is variable name, and 123
is integer constant.
Similarly for char a = 'a';
float a = 1.234;
char a[] = "asdf"; or char a[] = {'a', 'b', 'c'};
Reply all
Reply to author
Forward
0 new messages