New Microsoft Word Document

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 34

j

50.What is the return value of a printf() function?


The printf() function is used for printing the output.

It returns the number of characters that are printed.

If there is some error then it returns a negative value.

51.What is the return value of the scanf() function


The scanf() function is used for obtaining the input from the user.

It returns the number of input values that are scanned.

If there is some input failure or error then it returns EOF (end-of-file).

52.Is it possible to have nested printf()?


when multiple printf's appear inside another printf,

the inner printf prints its output and returns length of the string printed on the screen

before the outer printf prints

53. Input:
10,20,30

Output:

60

sum of all inputs

54. What is Type Casting?


In type casting, the compiler automatically changes one data type

to another one depending on what we want the program to do

55. What are the different types of typecasting available in C?


There are two different types of type casting in C that can be performed, which are:

Implicit type casting

Explicit type casting


56. What is the Syntax of explicit Type Casting?
(data_type)expression;]

57. What is Operator? Classification of Operators in C


An operator is a symbol that operates on a value or a variable.

For example: + is an operator to perform addition

Arithmetic Operator

Increment/Decrement Operator

Assignment Operator

Relational Operator

Logical Operator

bitwise operator

conditional operator

58.Difference between – Division and Modulo Operators


Modulo − Represents as % operator. And gives the value of the remainder of an integer division.

Division − represents as / operator. And gives the value of the quotient of a division

59.Difference between - = and == Operators


The “=” is an assignment operator is used to assign the value on the right to the variable on the
left.

The '==' operator checks whether the two given operands are equal or not. If so, it returns true

60. What will be the Output: 17/5 ?


it gives value of quotitent = 3

61. What will be the Output –


6/7=0

-6/-7 =0

-6/7=0
62. What will be the Output:
 -14%3=-2

 -14%-3=-2

 14%-3=2

(The sign which is assigned to the numerator will be printed in the result )

63. What will happen if we apply Arithmetic Operators on a char data


type?
—> it converts them into integer value automatically i.e. ASCII value of characters.

64. What will be the Output: 10.0 % 3.0 ?


—>If we use floating point values in modulo operator, we always get answer as 0.

65. How to apply the Modulo operation on a floating-point value?


—>fmod function with the header file math.h is used to get the modulo value for the float point
value.

66.Which Operator is used to find the power of a number?


—> exponent operator (^)

67. Describe about the short circuit functionality of the Logical


Operators.
—> In the case of logical AND (&&), the second operand does not get evaluated when the first
operand is false.

In the case of a logical OR(||),the second operand does not get evaluated if the first operand is true.

68. What is the difference between abs() and fabs() functions?


—> Both will return the absolute value of a number. But abs() will return a integer value and fabs()
will return a floating point value.
69. What is the difference between a++ and ++a?
—> a++(first assign the value and then increment the value by 1)

++a(first increment the value by 1 and then assign the value).

70. Why does n++ executes faster than n=n+1


—> n++ uses unary operator while n=n+1 uses binary operator.

71. What are the Bitwise Operators available in C? Can you describe
them?
—> && bitwise AND

|| bitwise OR

^ bitwise XOR

~ bitwise complimentary

>> bitwise right shift

<< bitwise left shift

72. Explain the use of comma operator.


—> we assign multiple values to a variable using comma, in that case comma is known as operator.

73. Which operator can be used to determine the size of a data type or
variable?
—> sizeof operator

For example: sizeof(int)

74. Give the classification of the Control Statements of C Programming


—> 3types

Decision making statements

Loop or iterative statements

Jump statements
75.Specify different types of Decision control statements?
—> if statement

If else

Else if

Nested if

Switch
90. What is a Global Variable?
The variable that is declared within a function is termed as local variable, while if the variable is
declared outside the function is known as global variable.
91. Suppose a global variable and local variable have the same name.
Is it possible to access a global variable from a block where local

variables are defined?

We can access global variable if there is a local variable with same name in C and C++ through
Extern and Scope resolution operator respectively.

92. Can variable belonging to different scope have same name?

Yes, variables belonging to different function can have same name because their scope is limited to
the block in which they are defined. Variables belonging to different functions in a single code can
have same name if we declare that variable globally

93. What is the default value of Local and Global Variables?


Default value→ All uninitialized global variables will have 0 as the default value.

Lifetime→ The lifetime of these variables is till the end of the execution of the program.There is no
default value for local variables, so local variables should be declared and an initial value should be
assigned before the first use.
94. List out the differences between Local Variable and Global
Variables?
95. What is an Array?

An array is a data structure consisting of a collection of elements (values or variables), each


identified by at least one array index or key

96. What are the characteristics of an array?


An array is a linear data structure that collects elements of the same data type and stores them in
contiguous and adjacent memory locations. Arrays work on an index system starting from 0 to (n-1),
where n is the size of the array.

97. What are the different types of Arrays?


Two-dimensional array. Multi-dimensional array.

99. What are the different ways to declare an array?


There are two ways you can declare and initialize an array in Java. The first is with the new keyword,
where you have to initialize the values one by one. The second is by putting the values in curly
braces.

100. When we do a partial initialization of an array, what will the value


stored in the rest of the indexes?
An array may be partially initialized, by providing fewer data items than the size of the array. The
remaining array elements will be automatically initialized to zero.

101. What is the meaning of base address of an array?


Base address of an array is the address value of the starting point of the array.It is usually the
address of the first element of the array. Explanation: Base address can be used to calculate the
other values of the array if width of array and all info is given.
102. What will be the value stored in the indexes of an array if it is not
initialized?
If an array is partially initialized, elements that are not initialized receive the value 0 of the
appropriate type. The same applies to elements of arrays with static storage duration. (All file-scope
variables and function-scope variables declared with the static keyword have static storage
duration.)

103. How do you access the values within an array?

How do you access the values within an array?

104. Can we pass an array in function as a parameter?


ust like normal variables, Arrays can also be passed to a function as an argument, but in C/C++
whenever we pass an array as a function argument then it is always treated as a pointer by a
function

105.Can we declare a static array


Statically declared arrays are allocated memory at compile time and their size is fixed, i.e., cannot be
change

106.Can we modify the value of an array?


We can change the contents of array in the caller function (i.e. test_change()) through callee
function (i.e. change) by passing the the value of array to the function (i.e. int *array). This
modification can be effective in the caller function without any return statement.

107.How to initialize all the elements of an array with zero?


The array will be initialized to 0 in case we provide empty initializer list or just specify 0 in the
initializer list. 

108. What happens when you attempt to go beyond the range of an array
you read or write outside of an array's bounds, you may read or write garbage or you may get a
segmentation fault which at least tells you there's a problem
109. What happens when you initialize the array values more the
declared size?
It throws garbage values

110. What are Designated Initializers?


designated initializer, or designator, points out a particular element to be initialized. A designator
list is a comma-separated list of one or more designators.

111 How to find the size of the array?


How to find the length of the array?
We can find the size of an array using the sizeof() operator

Length of Array = size of array/size of 1 datatype

113. What is a 3D array?3D array is a multi-dimensional array(array of


arrays).
A 3D array is a collection of 2D arrays . It is specified by using three subscripts:Block size, row size
and column size.

112. Prove that array has continuous memory allocation


Arrays store elements in contiguous memory locations, resulting in easily calculable addresses for
the elements stored and this allows faster access to an element at a specific index

114What is a Variable length array?Variable length arrays are also known as runtime sized
or variable sized arrays. The size of such arrays is defined at run-time

115. What are Functions?A function is a block of code which only runs when it is
called.Functions are used to perform certain actions, and they are important for reusing code:
Define the code once, and use it many times
.116. What are the different types of functions we have?There are two types of
function in C programming:

Standard library functions

User-defined functions

117. What are built-in functions?The system provided these functions and stored them in
the library. Therefore it is also called Library Functions. e.g. scanf(), printf(), strcpy, strlwr, strcmp,
strlen, strcat,

118. What are the Advantages and Disadvantages of using Functions?

By using functions, we can avoid rewriting same logic/code again and again in a program.

We can call C functions any number of times in a program and from any place in a program.

We can track a large C program easily when it is divided into multiple functions.

119. What is a Parameter? Why is it required?


The parameter in C refers to any declaration of variables within the parenthesis during the function
declaration. These are listed in the function's definition, separated by commas

.120. What is the use of the return Keyword


A return statement ends the execution of a function, and returns control to the calling function.

121.What is the difference between actual and formal parameters?


Actual parameters are those parameters that are specified in the calling function. formal parameters
are those parameters that are declared in the called function.

122.When is the void keyword used in Functions?


the void keyword specifies that the function doesn't return a value.

123. What are the different ways of passing parameters to the functions?
Which to use when?
There are two ways to pass parameters in C: Pass by Value, Pass by Reference.

Pass by Value. Pass by Value, means that a copy of the data is made and stored by way of the name
of the parameter. ...

Pass by Reference. A reference parameter "refers" to the original data in the calling function.

124.What is the Scope of a Function?


Scope is a concept that refers to where values and functions can be accessed.

125.What is the return type of a Function in C Programming?


Return Type − A function may return a value. The return_type is the data type of the value the
function returns

126.What is the purpose of placing the void keyword within the parameters
of the function?
to indicate that a function takes no arguments. to indicate that a function returns no value.

127.What is a Recursion
Recursion is the technique of making a function call itself.

128.What are the different types of recursions?


Recursion are mainly of two types. The first one is called direct recursion and another one is called
indirect recursion

129.What are the different types of variables we have in C Language


local variable.

global variable.

static variable.

automatic variable.

external variable.
130.What is a Static Function?
Static functions in C are functions that are restricted to the same file in which they are defined

175. What is a nested structure?


A nested structure in C is a structure within structure. One structure can be declared inside another
structure in the same way structure members are declared inside a structure.

176. Can you initialize the Structure members?

Structure members cannot be initialized like other variables inside the structure definition. This is
because when a structure is defined, no memory is allocated to the structure's data members at this
point. Memory is only allocated when a structure variable is declared.

177. Is Partial initialization possible for Structure variables?

178. How to pass a structure as a parameter to a function?

C allows programmers to pass a single or entire structure information to

or from a function.

 A structure information can be passed as a function argument.

 The function will return the value by using the return statement.

179. What is a self-referential structure?

The self-referential structure is a structure that points to the same type of structure. It contains one
or more pointers that ultimately point to the same structure.

180. When to use the -> (arroe operator)?

The -> (arrow) operator is used to access class, structure or union members using a pointer. A postfix
expression, followed by an -> (arrow) operator, followed by a possibly qualified identifier or a
pseudo-destructor name, designates a member of the object to which the pointer points.

181. What are Unions?

Union is an user defined datatype in C programming language. It is a collection of variables of


different datatypes in the same memory location.

182. What is the difference between structure and union?

In Structure, there is a specific memory location for every input data member. Thus, it can store
multiple values of the various members. In Union, there is an allocation of only one shared memory
for all the input data members. Thus, it stores one value at a time for all of its members.
183. What are enumeration?

Enumeration or Enum in C is a special kind of data type defined by the user. It consists of constant
integrals or integers that are given names by a user. The use of enum in C to name the integer values
makes the entire program easy to learn, understand, and maintain by the same or even different
programmer.

184. What are Command Line Arguments?

Command-line arguments are simple parameters that are given on the system's command line, and
the values of these arguments are passed on to your program during program execution. When a
program starts execution without user interaction, command-line arguments are used to pass values
or files to it.

185. Execute a C Program without using the main() Function

#include<stdio.h>

#define start main

void start()

printf("Hello");

You might also like