C programming Viva quesions
C programming Viva quesions
All the electronic/electrical components and circuits used in a computer system are called
hardware. A computer is actuated and controlled with the help of computer programs called
software.
An operating system is a collection of programs used to connect the user with the hardware
It has the set of programs which controls the operations of the hardware components such
as CPU, main memory, keyboard, monitor, printer and so on.
4) What is Algorithms?
An algorithms refer to the step by step instructions written to solve any problem.
5) What is Flowchart ?
char – a character
double – a floating-point number, with more precision and perhaps greater range than float
The Scanf () function can be used to get input into a program and it requires two arguments.
First a format specifier defines the type of data to be entered, then the name of the variable
in which the input will be stored. This scanf () function is responsible for giving input into the
program.
The printf() function is used to display/output values of variable in the monitor. The printf
function has general form: printf (“format specifiers”,variables)
10) What are the maximum and minimum possible ranges of values for long and short type?
If the int variable is created by default as a ‘long’ type it typically will have a possible range
of values from a maximum of +214748347 and a minimum of -2147483648. For ‘short’ type
these are the maximum and minimum values +327676 and minimum -32768.
(While answering this question you can specify the approximate value raised to power).
The preprocessor is a program which is executed before the compilation of a source program
written by the user. The preprocessor directives begins with hash (#) followed by the
command. e.g #include – it is a directive to include file.
12) What exactly is a ‘variable scope’, ‘local variables’ and ‘global variables’?
The extent to which a variable is accessible in a program is called the ‘variable scope’.
Variables declared internally inside a function are known as ‘local’ variables.
C programs are constructed from a set of reserved words which provide control and from
libraries which perform special functions. The basic instructions are built up using a reserved
set of words, such as main, for, if,while, default, double, extern, for, and int, to name just a
few.
All variables used in a C program are declared using the appropriate data types to enable the
compiler to allocate the required number by bytes in RAM to store values of these variables
in memory
An identifier is a name used to identify a variable, function, symbolic constant and so on.
Arithmetic operator
Relational operators
Logical Operators
5.Assignment operators
6.Conditional operator
Bitwise operators
Loop control structures are used to execute and repeat a block of statements depending on
the value of a condition. There are 3 types of loop control statements in C
for loop
while loop
do – while loop
A while loop has one control expression, and executes as long as that expression is true. The
general syntax of a while loop is
while( expression ){
statements
we use a while loop when a statement or group of statements which may have to be
executed a number of times to complete their task. The controlling expression represents
the condition
A for loop is used to execute and repeat a block of statements depending on a condition. The
syntax of a for loop is
for( ; ; )
statements
break statement
continue statement
goto statement
exit() function
An array is a collection of values of the same data type. Values in array are accessed using
array name with subscripts in brackets[]. Syntax of array declaration is
An array with more than one index value is called a multidimensional array. To declare a
multidimensional array you can do follow syntax
strlen();
trcpy();
strcat();
strcmp();
The header file #include is used when these functions are called in a C program.
A #if directive test can be offered with #else and #else if directives. This allows conditional
branching of the program to run sections of the code according to the result. Constants
defined with a #define directive can be undefined with the #undef directive. The #ifdef
directive has a companion directive #ifndef. These commands can be useful when debugging
problem code to hide and unhide sections of the program.
e.g. in the expression a=6+b*3, the order of precedence determines whether the addition or
the multiplication is completed first. Operators on the same row have equal precedence.
This function concatenates the source string at the end of the target string. Strcmp()
function compares two strings to find out whether they are the same or different. The two
strings are compared character by character until there is a mismatch or end of one of the
strings is reached, whichever occurs first. If in case two strings are identical, a value of zero is
returned. If there is no matches between two strings then a difference of the two non
matching values are returned according to ASCII values.
A function is a module or block of program code which deals with a particular task. Each
function has a name or identifier by which is used to refer to it in a program. A function can
accept a number of parameters or values which pass information from outside, and consists
of a number of statements and declarations, enclosed by curly braces { }, which make up the
doing part of the object
Built – in functions are used to perform standard operations such as finding the square root
of a number, absolute value and so on. These are available along with the C compiler and are
included in a program using the header files math.h, string.h and so on.
User defined functions are written by the user or programmer to compute a value or
perform a task. It contains a statement block which is executed during the runtime
whenever it is called by the main program.
A function which does not return a value directly to the calling program is referred as a void
function. The void functions are commonly used to perform a task and they can return many
values through global variable declaration.
A function calling itself again and again to compute a value is referred to as recursive
function or recursion. Recursion is useful for branching processes and is effective where
terms are generated successively to compute a value.
A simple network consist of computers connected using network interface cards, networking
software and network cables. There are two main networking arrangements
i) client / server – a powerful computer is used as the server which works as the interpreter
between the clients and helps sharing files.
ii)peer to peer – there is no server and all the workstations are treated equally.
Library functions are built in programs available along with the compiler which perform
some standard mathematical operations.
38) How does the type float differ from double in C language ?
Float data type refers real number in single precision and has 6 decimal digits. It takes 4
bytes in memory to refer values ranging from 3.4e-38 to 3.4e+38
double data type also refers to real number but in double precision and has 12 decimal
digits. It takes 8 bytes of memory to refer values ranging from 1.7e-308 to 1.7e+308
An operator performs an operation like addition, subtraction and so on and produce a value.
Variables and constants upon which operations are performed are called operands.
ROM – Read Only Memory is permanent storage medium which stores start up programs
(operating system programs) and BIOS programs which are recorded by the manufacturer of
the compiler system. ROM is a non-volatile memory.
System software is a collection of programs which are used to assist the user to handle the
computer hardware like printer, disk and so on and execute the application programs.
application softwares are programs which are used to solve specific problems /tasks.
Examples include railway reservation, banking and so on.
All the statements written in a program are executed from top to bottom one by one.
Control statements are used to execute / transfer the control from one part of the program
to another depending on a conditions.
Cost/Performance
Scalability
Long version: Open specifications for Multi-Processing via collaborative work between
interested parties from the hardware and software industry, government and academia.
48) Explain increment and decrements operators .
example : i++ (which adds one to i and results is scored back to)
Two major types of memory storage is primary memory and secondary memory. Primary
storage (or main memory or internal memory), often referred to simply as memory, is the
only one directly accessible to the CPU.
Secondary memory (or external memory) differs from primary storage in that it is not
directly accessible by the CPU. Some of the example for secondary memory includes floppy
disks, flash memory, magnetic tape, hard drives etc.
Input and Output Devices: Input devices are the hardware that are used for providing
information to the computer like mouse and keyboard and output devices are the hardware
that are used for receiving information from computer like monitor, printer or the sound
system.