C Program find Output code snippet SET - 5
|
||||||||||||||||
What will be the output of the program, if a short int is
2 bytes wide?
#include<stdio.h>
int main()
{
short int i = 0;
for(i<=5 &&
i>=-1; ++i; i>0)
printf("%u,", i);
return 0;
}
|
||||||||||||||||
Workspace
|
2.
|
What will be the output of the program?
#include<stdio.h>
int main()
{
float a = 0.7;
if(0.7 > a)
printf("Hi\n");
else
printf("Hello\n");
return 0;
}
|
|||||||||||||||
Workspace
|
3.
|
Which of the following statements are correct about an if-else statements
in a C-program?
|
|||||||||||||||
Workspace
|
4.
|
Can we use a switch statement to switch on strings?
|
|||||||
Workspace
|
5.
|
What will be the output of the program?
#include<stdio.h>
#include<math.h>
int main()
{
printf("%f\n",
sqrt(36.0));
return 0;
}
|
|||||||||||||||
Workspace
|
6.
|
Is it true that too many recursive calls may result into stack
overflow?
|
|||||||
Workspace
|
7.
|
A macro must always be defined in capital letters.
|
|||||||
Workspace
|
8.
|
In a macro call the control is passed to the macro.
|
|||||||
Workspace
|
9.
|
A header file contains macros, structure declaration and function
prototypes.
|
|||||||
Workspace
|
10.
|
Which of the following function sets first n characters of a string to
a given character?
|
|||||||||||||||
Workspace
|
11.
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
char str1[]
= "Hello";
char str2[10];
char *t, *s;
s =
str1;
t =
str2;
while(*t=*s)
*t++ = *s++;
printf("%s\n",
str2);
return 0;
}
|
|||||||||||||||
Workspace
|
12.
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
char str = "IndiaBIX";
printf("%s\n",
str);
return 0;
}
|
|||||||||||||||
Workspace
|
13.
|
If the size of pointer is 4 bytes then What will be the output of the
program ?
#include<stdio.h>
int main()
{
char *str[]
= {"Frogs", "Do", "Not", "Die", "They", "Croak!"};
printf("%d,
%d", sizeof(str),
strlen(str[0]));
return 0;
}
|
|||||||||||||||
Workspace
|
14.
|
Point out the error in the program?
#include<stdio.h>
int main()
{
FILE
*fp;
fp=fopen("trial", "r");
fseek(fp, "20",
SEEK_SET);
fclose(fp);
return 0;
}
|
|||||||||||||||
Workspace
|
15.
|
What will be the output of the program (myprog.c) given below if it is
executed from the command line?
cmd> myprog friday tuesday sunday
/* myprog.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%c",
*++argv[1]);
return 0;
}
|
|||||||||||||||
Workspace
|
16.
|
What will be the output of the program?
#include<stdio.h>
int main()
{
const int x=5;
const int *ptrx;
ptrx =
&x;
*ptrx = 10;
printf("%d\n",
x);
return 0;
}
|
|||||||||||||||
Workspace
|
17.
|
Point out the error in the program (in Turbo-C).
#include<stdio.h>
#define MAX 128
int main()
{
const int max=128;
char array[max];
char string[MAX];
array[0]
= string[0]
= 'A';
printf("%c
%c\n", array[0], string[0]);
return 0;
}
|
|||||||||||||||
Workspace
|
18.
|
Point out the error in the program.
#include<stdio.h>
const char *fun();
int main()
{
char *ptr =
fun();
return 0;
}
const char *fun()
{
return "Hello";
}
|
|||||||||||||||
Workspace
|
19.
|
Input/output function prototypes and macros are defined in which
header file?
|
|||||||||||||||
Workspace
|
20.
|
What will be the output of the program?
#include<stdio.h>
int main()
{
int i;
char c;
for(i=1;
i<=5; i++)
{
scanf("%c", &c); /*
given input is 'a' */
printf("%c", c);
ungetc(c, stdin);
}
return 0;
}
|
|||||||||||||||
|
Comments
Post a Comment