Vous êtes sur la page 1sur 9

C viva questions

1. Who developed C language?


a. C language was developed by Dennis Ritchie in 1970 at Bell Laboratories.
2. Which type of language is C?
a. C is a high – level language and general purpose structured programming
language.
3. What is a compiler?
a. Compile is a software program that transfer program developed in high level
language into executable object code
4. What is IDE?
a. The process of editing, compiling, running and debugging is managed by a single
integrated application known as Integrated Development Environment (IDE)
5. What is a program?
a. A computer program is a collection of the instructions necessary to solve a
specific problem.
6. What is an algorithm?
a. The approach or method that is used to solve the problem is known as algorithm.
7. What is structure of C program?
a. A C program contains Documentation section, Link section, Definition section,
Global declaration section, Main function and other user defined functions
8. What is a C token and types of C tokens?
a. The smallest individual units are known as C tokens. C has six types of tokens
Keywords, Constants, Identifiers, Strings, Operators and Special symbols.
9. What is a Keyword?
a. Keywords are building blocks for program statements and have fixed meanings
and these meanings cannot be changed.
10. How many Keywords (reserve words) are in C?
a. There are 32 Keywords in C language.
11. What is an Identifier?
a. Identifiers are user-defined names given to variables, functions and arrays.
12. What is a Constant and types of constants in C?
a. Constants are fixed values that do not change during the program execution.
Types of constants are Numeric Constants (Integer and Real) and Character
Constants (Single Character, String Constants).
13. What are the Back Slash character constants or Escape sequence characters
available in C?
a. Back Slash character constant are \t, \n, \0
14. What is a variable?
a. Variables are user-defined names given to memory locations and are used to store
values. A variable may have different values at different times during program
execution
15. What are the Data Types present in C?
a. Primary or Fundamental Data types (int, float, char), Derived Data types(arrays,
pointers) and User-Defined data types(structures, unions, enum)

1
16. How to declare a variable?
a. The syntax for declaring variable is
b. data type variable_name-1, variable_name-2,....variable_name-n;
17. What is meant by initialization and how we initialize a variable?
a. While declaring a variable assigning value is known as initialization. Variable can
be initialized by using assignment operator (=).
18. What are integer variable, floating-point variable and character variable?
a. A variable which stores integer constants are called integer variable. A variable
which stores real values are called floating-point variable. A variable which stores
character constants are called character variables.
19. How many types of operator or there in C?
a. C consist Arithmetic Operators (+, -, *, /,%), Relational Operators (<, <=, >, >=,
!=), Logical Operators (&&, ||, !), Assignment Operators (=, +=, -=, *=, /=),
Increment and Decrement Operators (++, --), Conditional Operator(?:), Bitwise
Operators(<<, >>, ~, &, |, ^) and Special Operators (. , ->, &, *, sizeof)
20. What is a Unary operator and what are the unary operators present in C?
a. An operator which takes only one operand is called unary operator. C unary
operators are
b. Unary plus (+), Unary minus (-), Increment and Decrement operators (++,--),
Address of operator (&), Value at operator (*), sizeof operator, ones complement
operator (~).
21. What is a ternary operator and which is called ternary operator is C?
a. An operator which takes three operands is called ternary operator. Conditional
operator (? :) is knows as ternary operator in C.
22. What is the use of modulus (%) operator?
a. The modulus operator produces the remainder of an integer division. It cannot be
used on floating point data.
23. What is the use of printf and scanf functions in C?
a. Values of variables and results of expressions can be displayed on the screen
using printf functions. Values to variables can be accepted through the keyboard
using scanf function.
24. What are the format codes used in printf and scanf functions in C?
a. %c (for reading or printing a single character), %d (for reading or printing signed
integer), %u (for reading or printing unsigned integer), %ld (for reading or
printing long signed integer), %lu (for reading or printing long unsigned integer),
%f (for reading or printing floating point value), %lf (for reading or printing
double floating point value), %Lf (for reading or printing long double value, %s
(for reading or printing string value)
25. What are the decision making statements available in C?
a. IF statement, Switch statement and conditional statement
26. What is the use of IF statement and how it works?
a. The IF statement is used to control the flow of execution of statements. It first
evaluates the given expression and then, depending on whether the value of the
expression is true or false, it transfers the control to a particular statement.

2
27. Forms of IF statements?
a. Simple IF statement, IF-ELSE statement, NESTED IF-ELSE statement and ELSE
IF ladder
28. How switch statement works?
a. The switch statement tests the value of a given variable against a list of case
values and when a match is found, block of statement associated with that case is
executed and if no match is found then the block of statements associated with the
optional default is executed. If default case not present, control goes to the
statement after the switch.
29. What is the difference between IF and SWITCH statement?
a. IF works on integers, floats and characters whereas SWITCH works on only
integers and characters. Switch statement cannot perform inequality comparisons
whereas IF can perform both equality and inequality comparisons.
30. How conditional operator (? :) works?
a. The conditional expression is evaluated first. If the expression is true then
expression after the question mark is executed otherwise expression after the
colon is executed
31. What is GOTO statement?
a. GOTO is an unconditional branching statement which transfer control to the
specified label
32. What is a LOOP?
a. Loop is a sequence of statements that are executed repeatedly
33. What are the types of LOOP control statement?
a. Entry-Controlled Loop statement and Exit-Controlled loop statement
34. What are the LOOP control statements present in C?
a. WHILE, DO-WHILE, FOR
35. What are the sections present in FOR loop?
a. Initialization section, Conditional section, increment or decrement section
36. How a FOR loop works?
a. In FOR loop first initialization section is executed, then given condition is
checked. If condition becomes true then body of the loop is executed after that
increment or decrement section is executed
37. What is the use of break statement?
a. Break statement is used to exit from a loop
38. What is an ARRAY?
a. Array is a collective name given to similar elements
39. How ARRAY elements are stored in memory?
a. Array elements are stored in consecutive memory locations
40. How we can initialize an ARRAY?
a. All the element are separated by comma and enclosed within braces
41. How to access array element?
a. Array elements can be accessed by using subscript
42. What is the difference between normal variable and array variable?
a. A variable can store only one value at a time whereas array variable can store
several value at a time.

3
43. What are the types of Array’s?
a. One-Dimensional array, Two-Dimensional array and Multi-Dimensional array
44. What is a TWO-DIMENSIONAL array?
a. A Two-Dimensional array is an array which has elements as one-dimensional
arrays?
45. What is a character array?
a. Array which can store several characters is called character array
46. How to initialize a character array?
a. Character arrays can be initialized by separating character constants with comma
and enclosed with in parenthesis or characters enclosed within double quotation
marks.
47. What is the difference between reading strings using scanf and gets?
a. Scanf can not read strings with multiple words whereas gets can read strings with
multiple words
48. What are the String-Handling functions available in C?
a. gets, puts, strcat, strcmp, strcpy and strlen.
49. What are the types of functions?
a. C functions are divided into two categories user-defined function and built-in
functions
50. What is a function?
a. Function is a self contained block of statement which is used to perform certain
task
51. Which are called built-in functions?
a. Printf, scanf, clrscr, gotoxy, string handling functions and file handling functions
52. What is function prototype declaration?
a. A function declaration is also known as function prototype declaration which
contains function return type, function name, parameter list and terminating
semicolon
53. What are formal arguments and actual arguments?
a. Arguments that are used in function calling are called actual arguments.
Arguments that are used in function definition are called formal arguments
54. What is a recursive function?
a. A function calling itself is called function recursion
55. What is call by value and call by reference?
a. Passing values to the called function is called call by value, passing addresses to
the called function is called call by reference
56. How to pass an array to a function?
a. Arrays are passed to a function by sending its address
57. What is a global variable and local variable?
a. Variables which are declared in the global section is called global variables and
Variables which are declared in a function or a block are called local variables
58. What is a pointer variable?
a. Pointer variable is a variable which can store address of another variable
59. How can we store address of a variable in a pointer?
a. By using address of operator we can store address of a variable in a pointer
60. How can we access a variable value using a pointer?

4
a. By using value at operator we can access a variable value using its pointer
61. What is the use of pointers?
a. Pointer are used to pass array and structures from function to another function
62. How many bytes a pointer variable occupies in memory?
a. A pointer variable irrespective of its type it occupies two bytes in memory
63. What are the storage classes available in C?
a. Auto, Static, Extern and Register
64. What is a structure?
a. Structure is a user-defined data type. Structure is a collective name given to
dissimilar elements
65. How to access structure members?
a. Structure members can be accessed using dot operator
66. How to initialize structure variable?
a. All the members are separated by comma and are enclosed within braces
67. What are the differences between structures and arrays?
a. Structures stores dissimilar values where as arrays stores similar values. One
structure variable can assigned to another structure variable whereas one array
variable cannot be assigned to another array variable
68. What is the size of a structure?
a. Sum of all the members size is becomes structure size
69. How to access structure member by its pointer?
a. We can use structure members using arrow operator with its pointer
70. What is a union?
a. Union is a user-defined data type which can store a value of different data types
71. What is the difference between structures and unions?
a. Structures can store several values at a time whereas unions can store one value at
a time. A structure size becomes sum of all its members whereas a union size
becomes size of a member whose size is largest
72. What are the types of files we can create using C?
a. We can create text and binary files using C
73. What are the file-handling functions present in C?
a. fopen, fclose, fgetc, fputc, fgets, fputs, fprintf, fscanf, fread, fwrite, fseek
74. What are the file opening modes present in C?
a. r, w, a, r+, w+, a+, rb, wb, rb+, wb+

1. What is Algorithms?
An algorithms refer to the step by step instructions written to solve any problem.
2. What is Flowchart ?
A flowchart is a diagrammatic or symbolic representation of an algorithms. It uses various
symbols to represent the operations to be performed.
3. Name the four basic data types in “C” language?
The four basic data types in “c” language are as follows
char – a character
int – an integer, in the range -32,767 to 32,767
long int – a larger integer (up to +-2,147,483,647)
float – a floating-point number

5
double – a floating-point number, with more precision and perhaps greater range than float
4. Describe at least five different format specifiers?
%d: -An integer whole number
%f: -a floating point number
%c: -a single character
%s: -a string of value of characters.
5. Define and explain scanf () function?
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.
6. Define and explain printf () function?
The printf() function is used to display/output values of variable in the monitor. The printf
function has general form: printf (“format specifiers”,variables)

7. 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).
8. What is preprocessor?
The preprocessor is a program which is executed before the compilation of a source program
written by the user. The preprocessor directives begines with hash (#) followed by the
command. e.g #include – it is a directive to include file.
9. 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.
Variables declared externally outside a function are known as ‘global’ variables.
10. What are signed values?
When an int variable is declared it can by default contain either positive of negative integer
values. These are known as ‘signed’ values. The range of positive values is determined by
your system.
11. Define reserved words.
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.
12. What is the purpose of type declaration in C ?
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
13. What is identifier ?
An identifier is a name used to identify a variable, function, symbolic constsnt and so on.
14. Mention the different types of operators used in C ?
Arithmetic operator

6
Relational operators
Logical Operators
Increment and decrements operators
Assignment operators
Conditional operator
Bitwise oprators
15. What is Loop control statements ?
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
16. explain 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
17. explain for loop .
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(initilaisation;condition;update )
{
Statements;
}

18. List a few unconditional control statement in C.


break statement
continue statement
goto statement
exit() function

19. What is an array ?


An array is a collection of values of the same data type. Values in array are accessed using
array name with subscripts in brackets[]. Synatax of array declaration is
data type array_ name[size];

20. What is Multidimensional Arrays


An array with more than one index value is called a multidimensional array. To declare a
multidimensional array you can do follow syntax
data type array_ name[] [] []….;

21. Define string ?


An array of characters is known as a string.for example

7
char st[8]; this statement declares a string array with 80 characters .

22. Mention four important string handling functions in C languages .


There are four important string handling functions in C languages .
strlen();
trcpy();
strcat();
strcmp();
The header file #include is used when these functions are called in a C program.
23. Explain about the constants which help in debugging?
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.
24. Define and explain about ! Operator?
The logical operator ! NOT is a unary operator that is used before a single operand. It returns
the inverse value of the given operand so if the variable “c” had a value of true then! C would
return value of false. The not operator is very much useful in C programs because it can
change the value of variables with successful iterations. This ensures that on each pass the
value is changed.

26. What is operator precedence?


Operator precedence defines the order in which C evaluates expressions.
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.
27. Explain about the functions strcat() and strcmp()?
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.

28. Define function


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

29. s Differentiate built-in functions and user – defined functions.


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, s tring.h and so on.

8
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.
30. Distinguish between actual and formal arguments.
Actual arguments are variables whose values are supplied to the function in any function call.
Formal arguments are variables used to receive the values of actual arguments from the
calling program.

31. Explain the concept and use of type void.


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.
32. What is recursion ?
A function calling itself again and again to compute a value is referref to as recursive
function or recursion. Recursion is useful for branching processes and is effective where
terms are generated successively to compute a value.

33. what are Library functions?


Library functions are built in programs available along with the compiler which perform
some standard mathematical operations.
34. 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
35. What is an operator and operand?
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.

36. What are control ststements ?


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.
37. What is Parallel Computation?
Computations that use multi-processor computers and/or several independent computers
interconnected in some way, working together on a common task.
Examples: CRAY T3E, IBM-SP, SGI-3K, Cluster of Workstations.
38. What are input and output device ?
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.

Vous aimerez peut-être aussi