C Program Viva1
C Program Viva1
C program viva1
const continue do d
An operator is a symbol that instructs a computer to perform certain operations. Operators are typically used
as part of mathematical or logical expressions.
14. What are the operators available in C?
Aritmetic Operators + – * / %
Assignment Operator += -= *= /= %=
Conditional Operator ?:
statement.
The
do
statement.
The
for
statement.
23. What is the use of the break statement?
The
break
statement can be used to accomplish an early exit from a loop. When a
break
statement is encountered inside a loop, the loop is immediately exited and the program continues with the
statement immediately following the loop.
24. What is the use of the continue statement?
The
continue
statement is used to skip a part of a loop. It causes the loop to be continued with the next iteration after
skipping any statements in between.
25. What is an array?
An Array is a collection of variables of a similar type that are referenced by a common name. There are three
types of arrays, namely,
One Dimensional Array
Two Dimensional Array
Multi DImensional Array
getch()
,
sqrt()
, etc.
The function that has to be defined by the user at the time of writing a program is called user-defined
functions.
30. What is the difference between a formal parameter and an actual parameter?
The parameters used in function definitions are called formal parameters and those used in function calls are
called actual parameters. The formal parameters list declares the variables that will receive the data sent by
the calling program.
31. What is recursion?
A technique where a function calls itself is known as recursion.
32. Distinguish between automatic and static variables.
All local variables that are declared inside a function are known as auto variables unless not specified. That
is, by default a local variable is an auto variable. An auto variable is created each time when the function is
called and destroyed when the program’s execution leaves the function.
A static variable is similar to an automatic variable. A static variable is declared once and only destroys when
the execution of the program finishes.
Automatic Variables Static Variables
Automatic variables are created when the A static variable is only initialized once, when the program is
function is called. compiled.
Automatic variables are destroyed when the The value of a static variable persists until the end of the
execution of the function is completed. program.
33. What do you mean by scope, visibility, and lifetime of a variable?
The region of a program in which a variable is available for use is called the scope of the variable.
The ability of a program to access a variable from the memory is the visibility of a variable.
The duration of time in which a variable exists in the memory during execution is the lifetime of a variable.
34. How does a structure differ from an array?
An array is a collection of data elements of the same type. Structures can have elements of different types.
An array is a derived data type whereas a structure is a user-defined data type.
An array can be used as a built-in datatype. All we have to do is declare and use the array. But in the case of
a structure, we have to design and declare it as a data structure before the structure variables are declared
and used.
35. Distinguish between a structure and union.
Both structure and union are user-defined data types in C. The major difference between a structure and a
union is in terms of storage. In structures, each member has its own storage location, but all the members of
a union share the same location. That is a union can handle only one member at a time.
36. What are the size of a structure and a union?
The total size of the structure is the sum of the size of every data member. The total size of a union is the
size of the largest data member.
37. What is meant by nested structures and arrays of structures?
The individual members of a structure can be other structures as well, such structure is called a nested
structure. That is, a structure may contain another structure as its member.
It is possible to declare an array of structures. The array will have individual structures as its elements.
38. What is a pointer?
Pointers are a special type of variable that is used to store the address of another variable as their values.
39. What is type conversion?
The process of converting a variable of one data type into another is referred to as typecasting. Casting
allows you to make this type of conversion explicit, or to force it when it wouldn’t normally happen.
40. What is the difference between a void pointer and a null pointer?
A pointer that holds a null value is called a null pointer. When a pointer has a null value it is not pointing
anywhere. A void pointer is a type of pointer that points to some data location in storage, which doesn’t have
any specific type.
That is null pointer is a value, while the void pointer is a type.
41. How does an append mode differ from a write mode in file management?
When the mode is ‘write’, a file is created if the file does not exist. If that file already exists, then the contents
are deleted before starting writing.
When the mode is ‘append’, the file is opened with current contents safe. If the file does not exist, then a file
with the specified name is created.
42. What is the significance of EOF in files?
‘EOF’ is a specific designation for a file marker that indicates the end of the data.
43. What is dynamic memory allocation?
The process of allocating memory at runtime is known as dynamic memory allocation.
44. What is the difference between a macro and a function in C?
Macros Functions
#endif
#ifdef
#ifndef
#undef
#pragma
#error
#49. What is the difference between functions and parameterized macros?
Macros Functions
All the macros will be processed before the program compiles. Functions are not preprocessed but compiled.
Before Compilation, the macro name is replaced by macro value. During function call, transfer of control takes place.