C Program find Output code snippet SET - 7
|
1.
|
How many times "IndiaBIX" is get printed?
#include<stdio.h>
int main()
{
int x;
for(x=-1;
x<=10; x++)
{
if(x < 5)
continue;
else
break;
printf("IndiaBIX");
}
return 0;
}
|
|||||||||||||||
Workspace
|
2.
|
What will be the output of the program?
#include<stdio.h>
int main()
{
int i=-3,
j=2, k=0, m;
m = ++i
&& ++j || ++k;
printf("%d,
%d, %d, %d\n", i, j, k, m);
return 0;
}
|
|||||||||||||||
Workspace
|
3.
|
What will be the output of the program?
#include<stdio.h>
int addmult(int ii, int jj)
{
int kk, ll;
kk = ii
+ jj;
ll = ii
* jj;
return (kk,
ll);
}
int main()
{
int i=3,
j=4, k, l;
k =
addmult(i, j);
l =
addmult(i, j);
printf("%d,
%d\n", k, l);
return 0;
}
|
|||||||||||||||
Workspace
|
4.
|
Will the following program print the message infinite number of times?
#include<stdio.h>
#define INFINITELOOP while(1)
int main()
{
INFINITELOOP
printf("IndiaBIX");
return 0;
}
|
|||||||
Workspace
|
5.
|
What will be the output of the program ?
#include<stdio.h>
int *check(static int, static int);
int main()
{
int *c;
c =
check(10, 20);
printf("%d\n",
c);
return 0;
}
int *check(static int i, static int j)
{
int *p, *q;
p =
&i;
q =
&j;
if(i
>= 45)
return (p);
else
return (q);
}
|
|||||||||||||||
Workspace
|
6.
|
If the size of integer is 4bytes, What will be the output of the
program?
#include<stdio.h>
int main()
{
int arr[] =
{12, 13, 14, 15, 16};
printf("%d,
%d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0]));
return 0;
}
|
|||||||||||||||
Workspace
|
7.
|
In the following program add a statement in the function fact() such
that the factorial gets stored in j.
#include<stdio.h>
void fact(int*);
int main()
{
int i=5;
fact(&i);
printf("%d\n",
i);
return 0;
}
void fact(int *j)
{
static int s=1;
if(*j!=0)
{
s = s**j;
*j = *j-1;
fact(j);
/* Add a statement here */
}
}
|
|||||||||||||||
Workspace
|
8.
|
What will be the output of the program if the array begins at address
65486?
#include<stdio.h>
int main()
{
int arr[] =
{12, 14, 15, 23, 45};
printf("%u,
%u\n", arr, &arr);
return 0;
}
|
|||||||||||||||
Workspace
|
9.
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
int i;
char a[] = "\0";
if(printf("%s",
a))
printf("The string is empty\n");
else
printf("The string is not
empty\n");
return 0;
}
|
|||||||||||||||
Workspace
|
10.
|
What will be the output of the following program in 16 bit platform
assuming that 1022 is memory address of the string "Hello1" (in
Turbo C under DOS) ?
#include<stdio.h>
int main()
{
printf("%u
%s\n", &"Hello1", &"Hello2");
return 0;
}
|
||||||||||||||||||||||
Workspace
|
11.
|
If a char is 1 byte wide, an integer is 2 bytes wide and a long
integer is 4 bytes wide then will the following structure always occupy 7
bytes?
struct ex
{
char ch;
int i;
long int a;
};
|
|||||||
Workspace
|
12.
|
Point out the error/warning in the program?
#include<stdio.h>
int main()
{
unsigned char ch;
FILE
*fp;
fp=fopen("trial", "r");
while((ch
= getc(fp))!=EOF)
printf("%c", ch);
fclose(fp);
return 0;
}
|
|||||||||||||||
Workspace
|
13.
|
What will be the output of the program
#include<stdio.h>
void fun(int);
int main(int argc)
{
printf("%d\n",
argc);
fun(argc);
return 0;
}
void fun(int i)
{
if(i!=4)
main(++i);
}
|
|||||||||||||||
Workspace
|
14.
|
Which of the following statements are correct about the program?
#include<stdio.h>
int main()
{
unsigned int num;
int i;
scanf("%u",
&num);
for(i=0;
i<16; i++)
{
printf("%d", (num<<i & 1<<15)?1:0);
}
return 0;
}
|
|||||||||||||||
Workspace
|
15.
|
What will be the output of the program?
#include<stdio.h>
int fun(int **ptr);
int main()
{
int i=10;
const int *ptr =
&i;
fun(&ptr);
return 0;
}
int fun(int **ptr)
{
int j = 223;
int *temp =
&j;
printf("Before
changing ptr = %5x\n", *ptr);
const *ptr =
temp;
printf("After
changing ptr = %5x\n", *ptr);
return 0;
}
|
|||||||||||||||
Workspace
|
16.
|
Can I increase the size of dynamically allocated array?
|
|||||||
Workspace
|
17.
|
It is necessary to call the macro va_end if va_start is
called in the function.
|
|||||||
Workspace
|
18.
|
What do the following declaration signify?
void (*cmp)();
|
|||||||||||||||
Workspace
|
19.
|
What will be the output of the program (in Turbo C 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;
}
|
|||||||||||||||
Workspace
|
20.
|
What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
char *i = "55.555";
int result1
= 10;
float result2
= 11.111;
result1
= result1+atoi(i);
result2
= result2+atof(i);
printf("%d,
%f", result1, result2);
return 0;
}
|
|||||||||||||||
|
Comments
Post a Comment