Enumerated types contain a list of constants that can be addressed in integer values. The idea behind enumerated types is to create new data types that can take on only a restricted range of values. Moreover, these values are all expressed as constants rather than magic numbers in fact, there should be no need to [...]
Also filed in
|
|
Structure
A structure is a collection of variables under a single name. These variables can be of different types, and each has a name which is used to select it from the structure. A structure is a convenient way of grouping several pieces of related information together.
A structure is combination of different data types. Structs are [...]
Also filed in
|
|
An array is a collection of objects of the same data type. The subscripting operator ([]) provides the mechanics for creating an index to array elements. This form of access is called indexing or subscripting. An array facilitates the coding of repetitive tasks by allowing the statements executed on each element to be put into [...]
Also filed in
|
|
printf offers more structured output than putchar. Its arguments are, in order; a control string, which controls what gets printed, followed by a list of values to be substituted for entries in the control string.
Also filed in
|
|
At the character level, getchar() reads one character at a time from stdin, while putchar() writes one character at a time to stdout.
#include
main()
{
int i;
int ch;
for( i = 1; i<= 5; ++i ) {
ch = getchar();
putchar(ch);
}
}
Also filed in
|
|
To indicate that the function does not return a value, declare it with a return type of void.Also to declare that there is no arguments with function just write void in place of it.
Syntax :
—-void function-name( void ){ body}——
A simple function is,
Also filed in
|
|
Functions are easy to use; they allow complicated programs to be parcelled up into small blocks, each of which is easier to write, read, and maintain.
A function is declared in the following manner:
return-type function-name(parameter-list,…)
{ body… }
return-type -is the variable type that the function returns. This can not be an array type . If not given, [...]
Also filed in
|
|
The return statement immediately ends the execution of a subprogram and returns control to the caller.
For a function of return type void, a return statement is not strictly necessary. If the end of such a function is reached without encountering a return statement, control is passed to the caller as if a return statement without [...]
Also filed in
|
|
A goto statement is allowed to jump within the scope of a variable length array. ”goto ” statement permits unstructured jumps.The goto statement branches unconditionally to a statement label or block label. The label must be unique within its scope.
Specifically, a “goto” statement cannot branch into an IF statement, CASE statement, LOOP statement, or sub-block.
[...]
Also filed in
|
|
break
We have already met break in the discussion of the switch statement. It is used to exit from a loop or a switch, control passing to the first statement beyond the loop or a switch. The break command will exit the most immediately surrounding loop regardless of what the conditions of the loop are. Break [...]
Also filed in
|
|
The C Switch case statements are a substitute for long if statements that compare a variable to several values. These values can be int ,char or any other types which allows multiple choice of a selection of items at one level of a conditional where it is a far neater way of writing multiple if statements:
[...]
Also filed in
|
|
ternary operator is used where if statement is simple.If the expression 1 is true it expression2 execute otherwise expression 3 will execute.
expression1 ? expression2: expression3
expression1 : Indicates condition for ternary operator.if this is true then expression2 will execute else expression3 will execute.
Also filed in
|
|
int is used to define integer numbers.
{
int Count;
Count = 8;
}
Integers are whole numbers with a machine dependent range of values. C has 3 classes of integer storage namely short int, int and long int. All of these data types have signed and unsigned forms. A short int requires half the space than [...]
Also filed in
|
|
for loop is used where the loop will be traversed a fixed number of times.
for (expression1; expression2; expression3)
{
block of statements;
}
1) expression1 : this allows you to initialise a variable.
2) expression2 : this gives the condition to loop.If it suppose to true then body of loop containing multiple statements will execute otherwise loop terminated.
Also filed in
|
|
We can define constants of any Data type by using the #define compiler directive. Its syntax is simple as under :
#define SALARY_MIN 1500
#define SALARY_MAX 15000
Also filed in
|
|
#include < stdio.h>
void main()
{
printf(”\nHello World\n”);
}
The statement above printf(”\nHello World\n”); is simple that it display the string hello world. But what about the \n part? the explanation for this question is given below.
Also filed in
|
|