C ans key
C ans key
Ans: Those control statements which are used for decision making purpose or for making
multi-way selection in the program are called Branching Statements. These statements
choose to follow one branch or another during execution in the program. Branching
statements are of the following two types:
Conditional Control Statements (if else)
Multiway Conditional Control Statement (switch case)
To create an empty array in C, you need to declare an array variable with a size of 0 or dynamically
allocate memory for the array. datatype array_name[0]; In C, declaring an array with a size of 0 is
legal, but it doesn't allocate any memory for the array elements. It effectively creates an array with
no elements.
3. Write some properties and advantages of user defined functions in C? Ans: Properties of Functions
- Every function has a unique name. This name is used to call function from “main()” function. - A
function performs a specific task. 3 Q&A for Previous Year Questions Subject: Computer
Programming(B.Tech. I Year)
--------------------------------------------------------------------------------------------------------------------------------------
---- - A function returns a value to the calling program.
Recursive functions are calculated by going backwards until the base case is reached. Following the
above recursive function for evaluating a factorial of 4, for example, the function states the factorial
of 4 is equal to 4 times the factorial of 4 minus 1, so the factorial of 4 is 4 times the factorial of 3.
1. In type casting, a data type is converted into another data type by a programmer using
casting operator. Whereas in type conversion, a data type is converted into another data type
by a compiler.
2. Type casting can be applied to compatible data types as well as incompatible data types.
Whereas type conversion can only be applied to compatible datatypes.
3. In type casting, casting operator is needed in order to cast a data type to another data type.
Whereas in type conversion, there is no need for a casting operator.
4. In typing casting, the destination data type may be smaller than the source data type, when
converting the data type to another data type. Whereas in type conversion, the destination data
type can’t be smaller than source data type.
5. Type casting takes place during the program design by programmer. Whereas type
conversion is done at the compile time.
6. Type casting is also called narrowing conversion because in this, the destination data type
may be smaller than the source data type. Whereas type conversion is also called widening
conversion because in this, the destination data type can not be smaller than the source data type.
7. Type casting is often used in coding and competitive programming works. Whereas
type conversion is less used in coding and competitive programming as it might cause incorrect
answer.
8. Type casting is more efficient and reliable. Whereas type conversion is less efficient
and less reliable.