C Program find Output code snippet SET - 8
|
||
1.
|
Which statement will you add in the following program to work it
correctly?
#include<stdio.h>
int main()
{
printf("%f\n",
log(36.0));
return 0;
}
|
|||||||||||||||
Workspace
|
2.
|
What will be the output of the program?
#include<stdio.h>
#define PRINT(i) printf("%d,",i)
int main()
{
int x=2,
y=3, z=4;
PRINT(x);
PRINT(y);
PRINT(z);
return 0;
}
|
|||||||||||||||
Workspace
|
3.
|
What will be the output of the program assuming that the array begins
at the location 1002 and size of an integer is 4 bytes?
#include<stdio.h>
int main()
{
int a[3][4]
= { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
printf("%u,
%u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1));
return 0;
}
|
|||||||||||||||
Workspace
|
4.
|
Which of the following statements correct about k used
in the below statement?
char ****k; |
|||||||||||||||
Workspace
|
5.
|
What does the following declaration mean?
int (*ptr)[10]; |
|||||||||||||||
Workspace
|
6.
|
What will be the output of the program in Turbo-C ?
#include<stdio.h>
int main()
{
int arr[5],
i=-1, z;
while(i<5)
arr[i]=++i;
for(i=0;
i<5; i++)
printf("%d, ", arr[i]);
return 0;
}
|
|||||||||||||||
Workspace
|
7.
|
What will be the output of the program in 16-bit platform (Turbo C
under DOS) ?
#include<stdio.h>
int main()
{
printf("%d,
%d, %d", sizeof(3.0f), sizeof('3'), sizeof(3.0));
return 0;
}
|
|||||||||||||||
Workspace
|
8.
|
Point out the error in the program?
#include<stdio.h>
int main()
{
struct emp
{
char name[20];
float sal;
};
struct emp
e[10];
int i;
for(i=0;
i<=9; i++)
scanf("%s %f", e[i].name,
&e[i].sal);
return 0;
}
|
|||||||||||||||
Workspace
|
9.
|
A structure can contain similar or dissimilar elements
|
|||||||
Workspace
|
10.
|
A pointer union CANNOT be created
|
|||||||
Workspace
|
11.
|
What will be the output of the program if value 25 given
to scanf()?
#include<stdio.h>
int main()
{
int i;
printf("%d\n",
scanf("%d", &i));
return 0;
}
|
|||||||||||||||
Workspace
|
12.
|
Point out the error in the program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
unsigned char;
FILE
*fp;
fp=fopen("trial", "r");
if(!fp)
{
printf("Unable to open file");
exit(1);
}
fclose(fp);
return 0;
}
|
|||||||||||||||
Workspace
|
13.
|
What will be the output of the program (sample.c) given below if it is
executed from the command line (turbo c under DOS)?
cmd> sample Good Morning
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%d
%s", argc, argv[1]);
return 0;
}
|
|||||||||||||||
Workspace
|
14.
|
What will be the output of the program (sample.c) given below if it is
executed from the command line?
cmd> sample friday tuesday sunday
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%c",
*++argv[2] );
return 0;
}
|
|||||||||||||||
Workspace
|
15.
|
Even if integer/float arguments are supplied at command prompt they
are treated as strings.
|
|||||||
Workspace
|
16.
|
If the different command line arguments are supplied at different
times would the output of the following program change?
#include<stdio.h>
int main(int argc, char **argv)
{
printf("%d\n",
argv[argc]);
return 0;
}
|
|||||||
Workspace
|
17.
|
What will be the output of the program?
#include<stdio.h>
typedef struct error
{int warning,
err, exception;} ERROR;
int main()
{
ERROR
e;
e.err=1;
printf("%d\n",
e.err);
return 0;
}
|
|||||||||||||||
Workspace
|
18.
|
What will be the output of the program?
#include<stdio.h>
int main()
{
const int i=0;
printf("%d\n",
i++);
return 0;
}
|
|||||||||||||||
Workspace
|
19.
|
Which standard library function will you use to find the last
occurance of a character in a string in C?
|
|||||||||||||||
Workspace
|
20.
|
Data written into a file using fwrite() can be read
back using fscanf()
|
|||||||
|
Comments
Post a Comment