A glance on the important concepts in C Programming follows.
I. What are Functions?
·
- is
a group of statements that accepts zero or more argument values as input
and produces a result value.
·
Every
function definition has the form:
return-type function-name (parameter declarations)
{
definitions and statements;
return(variable);
}
·
Uses
/ Adv of functions:
-
reduce
the complexity of the program
-
reuse
the functions
-
error
corrections are easier
-
reduce
the length of the program
II. Calling Functions:
Call by Value and Call by Reference ?
-
in
call by value, the values are passed to the called function by
the calling function.
-
in
call by reference, the memory address of values are passed to the
called function by the calling function.
III. Built-in functions VS
user defined functions?
Ex of built-in functions: - sqrt( ), strlen( ), …..
Ex of user defined functions: - largest( ), myaddress(
)….
-
User defined functions are those written by auser in his program
VI. Formal arguments VS
actual arguments?
·
When
call by value function call is used, the values are passed to another set of
variable declared in the called function. Now,
the variables passed in the calling functions is the actual
arguments and the variables of called function is the Formal
arguments.
V. Preprocessor directives?
-
these
are the statements that are executed before the program execution. Or, they are
the statements executed during the compilation time.
-
Ex:
#include<stdio.h>
#define n 25
VI. Header files?
supports the built-in functions used by a programmer
Ex: stdio.h, math.h ….
VII. What are loop statements?
- used for repeatedly executing a set of statements a
particular number of times.
- 3 types of loops:
1.
for loop
2.
while loop
3.
do – while loop
Ex: loop for repeating 25
times:
for loop
|
while loop
|
do – while loop
|
for( i=0; i<25; i++)
{
statements;
}
|
i=0;
while( i<25)
{
statements;
i++;
}
|
i=0;
do
{
statements;
i++;
} while( i< 25);
|
Loop repeats as
long the given condition, (i < 25), is TRUE
|
Loop repeats as
long the given condition, (i < 25), is TRUE
|
Loop repeats
as least once even if the condition (i < 25) is FALSE
|
VIII. Explain getch( ) function?
-
is
an input function for accepting a character
-
Ex:
main() {
char k;
k=getch();
printf(“ The character you just entered is
%c”, k );
}
IX. What are Pointers?
Syntax: dataType
*pointername;
Ex: int
*p; // declares p as a pointer variable
that points to integer data type.
main( )
{
int
q = 55;
int
*S;
S =
&q;
printf(“
The value in q is %c”, q ); // using
directly the variable name q.
printf(“
The value in q is %c”, *S ); //accessing the value using the pointer *S.
}
x. Compare Structures VS Unions?
Structures
|
Unions
|
struct <structureName> {
member type 1;
member type 2;
.
.
}variable;
|
union <unionName> {
member type 1;
member type 2;
.
.
}variable;
|
- Can Store all its
members’ value at a time.
- hence allocates space for
all member variables
|
Can Stores ONLY ONE member
value at a time.
- hence allocates space for
ONLY largest member variable.
|
***** GOOD LUCK *****
No comments:
Post a Comment