C Programming and Problem Solving
Questions 51 to 60
51.
|
What is printed when this program is
executed
int f( int x) {
if ( x<= 4)
return x;
return f(--x);
}
void main() {
printf ("%d\n", f(7));
}
|
||||||||||
Find the output for the following C
program
Y=10;
if(
Y++>9 && Y++!=10 && Y++>10)
printf("%d",
Y);
else
printf("%d",
Y);
|
|||||||||||
What are the values of a, b are if
the following code fragment is executed
int a ,b=7;
a=b<4?b<<1:b>4?7>>1:a;
|
|||||||||||
Find the
output of the following program:
#define INC(X) X++
void main()
{
int X=4;
printf("%d",INC(X++));
}
|
|||||||||||
The given statement FILE *fptr;
|
|||||||||||
Consider the following code
struct account {
int acno;
}svar, *pv = &svar;
then the acno can be accessed by
|
|||||||||||
Pick the equivalent control
structure for the following repetitive control structure
for( C1; C3; C2 ) { statements; }
|
|||||||||||
What is the correct output of the
following program?
# include
<string.h>
void main()
{
char
str[] = ”C EXAMINATION”, rev[17];
int
i = strlen(str), j=0;
for(
; i>=0; rev[j++] = str[i--]);
rev[j]
= ‘\0’;
puts(rev);
}
|
|||||||||||
Choose the correct output for the
following program
# include
<stdio.h>
void main(){
int
a=10, b=11, c=13, d;
d
= (a=c, b+=a, c=a+b+c);
printf(“
%d, %d”, d, a);
}
|
|||||||||||
In ‘C’ which of the following can be
used to create the constants for float values?
I. Enumerations
II. const III. # define
|
Answers
51.
|
A
|
In this recursive function call the function return to
main caller when the value of x is 4. Hence the output
|
D
|
What so ever the outcome of the expression is Y is post
incremented three times.
|
|
C
|
7>>1 shifts 7 towards left by 1 position and
hence 3 will be assigned to a. variable b remains same.
|
|
D
|
L valve required for this expression INC(X++++) which
is illegal.
|
|
A
|
FILE is a pre-defined structure.
|
|
D
|
As all the ways are legal and valid.
|
|
D
|
C1, C3, C2 are place holders for initialization part,
condition part and the increment/decrement part. Hence both options for for
loop and while loop are same.
|
|
E
|
As i is with the length of string and hence in array
rev the contents are copied as “\0 NOITANIMAXE C”. But while displaying those
contents with puts function it stops because of the first character ‘\0’ and
hence no output.
|
|
A
|
for any comma separated expression the out come is the
right most part.
|
|
D
|
As Enumerations can’t be used to create the float
constants.
|
C > Data Structures Code Examples
ReplyDeletethank you.
ReplyDeletec++ tutorial
java tutorial