C Program find Output code snippet SET - 3
1.
|
Which of the following cannot be checked in a switch-case statement?
|
|||||||||||||||
Workspace
|
2.
|
Point out the error, if any in the program.
#include<stdio.h>
int main()
{
int a = 10, b;
a
>=5 ?
b=100: b=200;
printf("%d\n",
b);
return 0;
}
|
|||||||||||||||
Workspace
|
3.
|
Which of the following statements are correct about the program?
#include<stdio.h>
int main()
{
int x = 30, y = 40;
if(x ==
y)
printf("x is equal to y\n");
else if(x
> y)
printf("x is greater than y\n");
else if(x
< y)
printf("x is less than y\n")
return 0;
}
|
|||||||||||||||
Workspace
|
4.
|
What will be the output of the program?
#include<stdio.h>
int main()
{
int i=4,
j=-1, k=0, w, x, y, z;
w = i
|| j || k;
x = i
&& j && k;
y = i
|| j &&k;
z = i
&& j || k;
printf("%d,
%d, %d, %d\n", w, x, y, z);
return 0;
}
|
|||||||||||||||
Workspace
|
5.
|
Are the following two statement same?
|
|||||||
Workspace
|
6.
|
Macros have a local scope.
|
|||||||
Workspace
|
7.
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
char *str;
str = "%d\n";
str++;
str++;
printf(str-2, 300);
return 0;
}
|
|||||||||||||||
Workspace
|
8.
|
Is this a correct way for NULL pointer assignment?
int i=0; char *q=(char*)i; |
|||||||
Workspace
|
9.
|
What will be the output of the program if the array begins at 65472
and each integer occupies 2 bytes?
#include<stdio.h>
int main()
{
int a[3][4]
= {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};
printf("%u,
%u\n", a+1, &a+1);
return 0;
}
|
|||||||||||||||
Workspace
|
10.
|
The library function used to reverse a string is
|
|||||||||||||||
Workspace
|
11.
|
What will be the output of the program ?
#include<stdio.h>
#include<string.h>
int main()
{
char sentence[80];
int i;
printf("Enter
a line of text\n");
gets(sentence);
for(i=strlen(sentence)-1;
i >=0; i--)
putchar(sentence[i]);
return 0;
}
|
|||||||||||||||
Workspace
|
12.
|
What will be the output of the program ?
#include<stdio.h>
struct course
{
int courseno;
char coursename[25];
};
int main()
{
struct course
c[] = { {102, "Java"},
{103, "PHP"},
{104, "DotNet"} };
printf("%d
", c[1].courseno);
printf("%s\n",
(*(c+2)).coursename);
return 0;
}
|
|||||||||||||||
Workspace
|
13.
|
Point out the error in the program?
struct emp
{
int ecode;
struct emp *e;
};
|
|||||||||||||||
Workspace
|
14.
|
On declaring a structure 0 bytes are reserved in memory.
|
|||||||
Workspace
|
15.
|
On executing the below program what will be the contents of
'target.txt' file if the source file contains a line "To err is
human"?
#include<stdio.h>
int main()
{
int i, fss;
char ch,
source[20] = "source.txt",
target[20]="target.txt", t;
FILE
*fs, *ft;
fs =
fopen(source, "r");
ft =
fopen(target, "w");
while(1)
{
ch=getc(fs);
if(ch==EOF)
break;
else
{
fseek(fs, 4L,
SEEK_CUR);
fputc(ch,
ft);
}
}
return 0;
}
|
|||||||||||||||
Workspace
|
16.
|
What will be the output of the program (sample.c) given below if it is
executed from the command line (Turbo C in DOS)?
cmd> sample 1 2 3
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
int j;
j =
argv[1] + argv[2] + argv[3];
printf("%d",
j);
return 0;
}
|
|||||||||||||||
Workspace
|
17.
|
In Turbo C/C++ under DOS if we want that any wild card characters in
the command-line arguments should be appropriately expanded, are we required
to make any special provision?
|
|||||||
Workspace
|
18.
|
Bitwise | can be used to multiply a number by powers of 2.
|
|||||||
Workspace
|
19.
|
What do the following declaration signify?
int *f();
|
|||||||||||||||
Workspace
|
20.
|
What will be the output of the program under DOS?
#include<stdio.h>
int main()
{
char huge
*near *far *ptr1;
char near
*far *huge *ptr2;
char far
*huge *near *ptr3;
printf("%d,
%d, %d\n", sizeof(ptr1), sizeof(**ptr2), sizeof(ptr3));
return 0;
}
|
|||||||||||||||
|
Comments
Post a Comment