- Home
- Interview Questions
- C Programming
A block is a group of statements enclosed in braces ({}). A block can be used in most places that a statement can be used.
The main() function.
Machine language is made up of digital or binary instructions that the computer can understand. Because the computer can't understand C source code, a compiler translates source code to machine code, also called object code.
A function is an independent section of program code that performs a certain task and has been assigned a name. By using a function's name, a program can execute the code in the function.
A user-defined function is created by the programmer. A library function is supplied with the C compiler.
An include file is a separate disk file that contains information needed by the compiler to use various functions.
A long int variable takes up more RAM than the smaller int. In smaller programs, this doesn't pose a problem. As programs get bigger, however, you should try to be efficient with the memory you use.
You can assign a number with a decimal to an int variable. If you're using a constant variable, your compiler probably will give you a warning. The value assigned will have the decimal portion truncated. For example, if you assign 3.14 to an integer variable called pi, pi will only contain 3. The .14 will be chopped off and thrown away.
Many compilers will allow this without signaling any errors. The number is wrapped to fit and therefore won't be correct. For example, if you assign 32768 to a two-byte signed variable of type short, the variable would really contain the value -32768. If you assign the value 65535 to this variable, it really contains the value - 1. Subtracting the maximum value that the field will hold generally gives you the value that will be stored.
As the preceding answer indicated, your compiler might not signal any errors if you do this. The compiler does the same wrapping as if you assigned a number that was too big. For instance, if you assign -1 to an unsigned int variable that is two bytes long, the compiler will put the highest number possible in the variable (65535).