C Program find Output code snippet SET - 1
|
What
will be the output of the program?
#include<stdio.h>
int main()
{
int x=1, y=1;
for(; y; printf("%d %d\n", x, y))
{
y = x++ <= 5;
}
printf("\n");
return 0;
}
|
|||||||||||||||
|
2.
|
Which of
the following is the correct order of evaluation for the below expression?
z = x + y * z / 4 % 2 - 1 |
|||||||||||||||
|
3.
|
Which of
the following range is a valid long double ?
|
|||||||||||||||
|
4.
|
Will the
printf() statement print the same values for any values of a?
#include<stdio.h>
int main()
{
float a;
scanf("%f", &a);
printf("%f\n", a+a+a);
printf("%f\n", 3*a);
return 0;
}
|
|||||||
|
5.
|
What
will be the output of the program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i=0;
i++;
if(i<=5)
{
printf("KIIT");
exit(1);
main();
}
return 0;
}
|
|||||||||||||||
|
6.
|
What
will be the output of the program ?
#include<stdio.h>
int main()
{
int i, a[] = {2, 4, 6, 8, 10};
change(a, 5);
for(i=0; i<=4; i++)
printf("%d, ", a[i]);
return 0;
}
void change(int *b, int n)
{
int i;
for(i=0; i<n; i++)
*(b+1) = *(b+i)+5;
}
|
|||||||||||||||
|
7.
|
What
will be the output of the program if the array begins 1200 in memory?
#include<stdio.h>
int main()
{
int arr[]={2, 3, 4, 1, 6};
printf("%u, %u, %u\n", arr, &arr[0], &arr);
return 0;
}
|
|||||||||||||||
|
8.
|
Which of
the following is correct way to define the function fun() in the below
program?
#include<stdio.h>
int main()
{
int a[3][4];
fun(a);
return 0;
}
|
|||||||||||||||
|
9.
|
What
will be the output of the program ?
#include<stdio.h>
int main()
{
printf(5+"Interview\n");
return 0;
}
|
|||||||||||||||
|
10.
|
What
will be the output of the program ?
#include<stdio.h>
int main()
{
enum status {pass, fail,
absent};
enum status stud1,
stud2, stud3;
stud1 = pass;
stud2 = absent;
stud3 = fail;
printf("%d %d %d\n", stud1, stud2, stud3);
return 0;
}
|
|||||||||||||||
|
11.
|
Point
out the error in the program?
struct emp
{
int ecode;
struct emp e;
};
|
|||||||||||||||
|
12.
|
What
will be the output of the program ?
#include<stdio.h>
int main()
{
FILE *ptr;
char i;
ptr = fopen("myfile.c", "r");
while((i=fgetc(ptr))!=NULL)
printf("%c", i);
return 0;
}
|
|||||||||||||||
|
13.
|
While
calling the fprintf() function in the format string conversion
specifier %s can be used to write a character string in capital
letters.
|
|||||||
|
14.
|
The
maximum combined length of the command-line arguments including the spaces
between adjacent arguments is
|
|||||||||||||||
|
15.
|
Which of
the following statements are correct about the program?
#include<stdio.h>
char *fun(unsigned int num, int base);
int main()
{
char *s;
s=fun(128, 2);
s=fun(128, 16);
printf("%s\n",s);
return 0;
}
char *fun(unsigned int num, int base)
{
static char buff[33];
char *ptr = &buff[sizeof(buff)-1];
*ptr = '\0';
do
{
*--ptr = "0123456789abcdef"[num %base];
num /=base;
}while(num!=0);
return ptr;
}
|
|||||||||||||||
|
16.
|
What
will be the output of the program?
#include<stdio.h>
int main()
{
const c = -11;
const int d = 34;
printf("%d, %d\n", c, d);
return 0;
}
|
|||||||||||||||
|
17.
|
Point
out the correct statement will let you access the elements of the array using
'p' in the following program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i, j;
int(*p)[3];
p = (int(*)[3])malloc(3*sizeof(*p));
return 0;
}
|
|||||||||||||||
|
18.
|
What do
the following declaration signify?
char *arr[10];
|
|||||||||||||||
|
19.
|
Point
out the error in the following program.
#include<stdio.h>
#include<string.h>
int main()
{
char str1[] = "Learn through IndiaBIX\0.com", str2[120];
char *p;
p = (char*) memccpy(str2, str1, 'i', strlen(str1));
*p = '\0';
printf("%s", str2);
return 0;
}
|
|||||||||||||||
|
20.
|
Point
out the error in the following program.
#include<stdio.h>
int main()
{
char str[] = "IndiaBIX";
printf("%.#s %2s", str, str);
return 0;
}
|
|||||||||||||||
|
||||||||||||||||
|
Provide your Output in Comments. We will publish the output soon. | ||||||
Comments
Post a Comment