C Program find Output code snippet SET - 10
1.
|
Which of the following statements are correct about the below
C-program?
#include<stdio.h>
int main()
{
int x = 10, y = 100%90,
i;
for(i=1;
i<10; i++)
if(x !=
y);
printf("x = %d y = %d\n", x, y);
return 0;
}
|
|||||||||||||||
Workspace
|
2.
|
What will be the output of the program?
#include<stdio.h>
int main()
{
int k,
num=30;
k =
(num>5 ? (num
<=10 ? 100 : 200): 500);
printf("%d\n",
num);
return 0;
}
|
|||||||||||||||
Workspace
|
3.
|
Point out the error in the following 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
|
4.
|
The keyword used to transfer control from a function back to the
calling function is
|
|||||||||||||||
Workspace
|
5.
|
Which of the following statements are correct about the function?
long fun(int num)
{
int i;
long f=1;
for(i=1;
i<=num; i++)
f = f * i;
return f;
}
|
|||||||||||||||
Workspace
|
6.
|
Which of the statements is correct about the program?
#include<stdio.h>
int main()
{
float a=3.14;
char *j;
j =
(char*)&a;
printf("%d\n",
*j);
return 0;
}
|
|||||||||||||||
Workspace
|
7.
|
Will the program compile in Turbo C?
#include<stdio.h>
int main()
{
int a=10,
*j;
void *k;
j=k=&a;
j++;
k++;
printf("%u
%u\n", j, k);
return 0;
}
|
|||||||
Workspace
|
8.
|
Which of the following statements are correct about an array?
|
|||||||||||||||
Workspace
|
9.
|
The library function used to find the last occurrence of a character
in a string is
|
|||||||||||||||
Workspace
|
10.
|
If char=1, int=4, and float=4 bytes
size, What will be the output of the program ?
#include<stdio.h>
int main()
{
char ch = 'A';
printf("%d,
%d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f));
return 0;
}
|
|||||||||||||||
Workspace
|
11.
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
char str[] = "Nagpur";
str[0]='K';
printf("%s,
", str);
str = "Kanpur";
printf("%s",
str+1);
return 0;
}
|
|||||||||||||||
Workspace
|
12.
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
int i=4,
j=8;
printf("%d,
%d, %d\n", i|j&j|i, i|j&j|i, i^j);
return 0;
}
|
|||||||||||||||
Workspace
|
13.
|
Bit fields CANNOT be used in union.
|
|||||||
Workspace
|
14.
|
Which of the following statement is correct about the program?
#include<stdio.h>
int main()
{
FILE
*fp;
char ch;
int i=1;
fp =
fopen("myfile.c", "r");
while((ch=getc(fp))!=EOF)
{
if(ch == '\n')
i++;
}
fclose(fp);
return 0;
}
|
|||||||||||||||
Workspace
|
15.
|
The first argument to be supplied at command-line must always be count
of total arguments.
|
|||||||
Workspace
|
16.
|
What will be the output of the program?
#include<stdio.h>
int main()
{
char c=48;
int i,
mask=01;
for(i=1;
i<=5; i++)
{
printf("%c", c|mask);
mask = mask<<1;
}
return 0;
}
|
|||||||||||||||
Workspace
|
17.
|
What is the output of the program?
typedef struct data;
{
int x;
sdata
*b;
}sdata;
|
|||||||||||||||
Workspace
|
18.
|
Which header file should you include, if you are going to develop a
function, which can accept variable number of arguments?
|
|||||||||||||||
Workspace
|
19.
|
Point out the error in the following program.
#include<stdio.h>
#include<stdarg.h>
void varfun(int n,
...);
int main()
{
varfun(3, 7,
-11.2, 0.66);
return 0;
}
void varfun(int n, ...)
{
float *ptr;
int num;
va_start(ptr,
n);
num =
va_arg(ptr, int);
printf("%d",
num);
}
|
|||||||||||||||
Workspace
|
20.
|
va_list is an array that
holds information needed by va_arg and va_end
|
|||||||
|
Comments
Post a Comment