Programming and data structure miscellaneous
- Consider the following C program segment :
char p [20]
char *s = “string”;
int length = strlen (s);
for (i = 0; i < length, i++)
p[i] = s [length – i];
print f(“%s”, p);
The output of the program is
-
View Hint View Answer Discuss in Forum
Let us consider below line inside the for loop.
P[i] = S[length – i];
For i = 0, P[i] will be S[6 – 0) and S [6] is ‘10’.
So, P[0] becomes ‘10’. It does not matter what comes in P[1], P[2] ........ as P[0] will not change for i > 0.
Nothing is Printed if we print a string with first character ‘10’.Correct Option: D
Let us consider below line inside the for loop.
P[i] = S[length – i];
For i = 0, P[i] will be S[6 – 0) and S [6] is ‘10’.
So, P[0] becomes ‘10’. It does not matter what comes in P[1], P[2] ........ as P[0] will not change for i > 0.
Nothing is Printed if we print a string with first character ‘10’.
- Match the following List I with List II and select the correct answer using the codes given below the lists.
-
View Hint View Answer Discuss in Forum
P. Functional programming is declarative in nature, involves expression evaluation, & side effect free.
Q. Logic is also declarative but involves theorem proving.
R. Object oriented is imperative statement based & have abstract (general) data types.
S. Imperative: The programs are made giving commands & follows definite procedure & sequence.
Hence (d) is correct option.Correct Option: D
P. Functional programming is declarative in nature, involves expression evaluation, & side effect free.
Q. Logic is also declarative but involves theorem proving.
R. Object oriented is imperative statement based & have abstract (general) data types.
S. Imperative: The programs are made giving commands & follows definite procedure & sequence.
Hence (d) is correct option.
- What does the following C-statement declare?
int (*f) int*);
-
View Hint View Answer Discuss in Forum
Syntax to declare pointer to a function => datatype (*pointer_variable)(list of arguments)
To make a pointer to a function => pointer_variable = function_name
Note : don't use parenthesis of the function.
To call (invoke) the function => pointer_variable (list of arguments)Correct Option: C
Syntax to declare pointer to a function => datatype (*pointer_variable)(list of arguments)
To make a pointer to a function => pointer_variable = function_name
Note : don't use parenthesis of the function.
To call (invoke) the function => pointer_variable (list of arguments)
- An Abstract Data Type (ADT) is
-
View Hint View Answer Discuss in Forum
An abstract data type is a mathematical model for a certain class of data structures that have similar behaviour. An abstract data type is indirectly defined by the operations and mathematical constraints thus, is a user defined data type, not a system defined, that can perform operations defined by it on that data.
Correct Option: C
An abstract data type is a mathematical model for a certain class of data structures that have similar behaviour. An abstract data type is indirectly defined by the operations and mathematical constraints thus, is a user defined data type, not a system defined, that can perform operations defined by it on that data.
- A common property of logic programming languages and functional languages is
-
View Hint View Answer Discuss in Forum
Languages needs declaration of any statement that we write before its use thus, the common property of both the languages is that both are declarative.
Correct Option: C
Languages needs declaration of any statement that we write before its use thus, the common property of both the languages is that both are declarative.