Thursday, 26 May 2011

C program part1

1.What does the term cast refer to? Why is it used?

A Casting is a mechanism built into C that allows the programmer to force the conversion of data types. This may be needed because most C functions are very particular about the data types they process. A programmer may wish to override the default way the C compiler promotes data types.
2.In arithmetic expressions, to what data type will the C compiler promote a character?

It will promote it to an integer unless otherwise directed.
3.What is the difference between a statement and a block?
A statement is a single C expression terminated with a semicolon. A block is a series of statements, the group of which is enclosed in curly-braces.
4.Increment the variable next three different ways.
next = next + 1;
and
next++;
and
next += 1;
5.How is a comment formed in C.
Comments in C begin with a slash followed by an asterisk. Any text may then appear including newlines. The comment is finished with an asterisk followed by a slash. Example:
/* This is a comment */ 

No comments:

Post a Comment