Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

C PROGRAM QUESTIONS : PART 31

What is the output of the following code?
#include
void main()
{
int s=0;
while(s++<10)>
# define a 10
main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}

10..10
10..50
 Error
 0
SHOW ANSWER

main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
What is the output of this program?

program will not compile
10
god only knows
address of I
SHOW ANSWER

What will happen if in a C program you assign a value to an array element whose subscript exceeds
the size of array?

The element will be set to 0.
The compiler would report an error.
The program may crash if some important data gets overwritten.
The array size would appropriately grow.
SHOW ANSWER

What would be the output of the following program?
#include
main()
{
char str[]="S\065AB";
printf("\n%d", sizeof(str));
}

7
 6
5
error
SHOW ANSWER

What will be the value of `a` after the following code is executed
#define square(x) x*x
a = square(2+3)

25
13
11
10
SHOW ANSWER

#include
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( "%d -- %d\n", x, y );
}
int main()
{
func();
func();
return 0;
}
What will the code above print when it is executed?


1 -- 1
1 -- 1 


1 -- 1
2 -- 1

1 -- 1
2 -- 2

1 -- 1
1 -- 2
SHOW ANSWER

long factorial (long x)
{
????
return x * factorial(x - 1);
}
With what do you replace the ???? to make the function shown above return the correct answer?


if (x == 0) return 0;


return 1;

if (x >= 2) return 2;

if (x <= 1) return 1;
SHOW ANSWER

int y[4] = {6, 7, 8, 9};
int *ptr = y + 2; printf("%d\n", ptr[ 1 ] );
What is printed when the sample code above is executed?

6
 7
8
 9
SHOW ANSWER

int i = 4;
switch (i)
{
default: ;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i *= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
printf("i = %d\n", i);
What will the output of the sample code above be?

i = 5
 i = 8
 i = 9
 i = 10
SHOW ANSWER

 What will be output if you will compile and execute the following c code?
void main()
{
if(printf("cquestionbank"))
printf("I know c");
else
printf("I know c++");
}

I know c
I know c++
cquestionbankI know c
cquestionbankI know c++
 Compiler error
SHOW ANSWER

What will be output if you will compile and execute the following c code?
#define call(x) #x
void main(){
printf("%s",call(c/c++));
}

c
c++
#c/c++
c/c++
Compiler error
SHOW ANSWER

What will be output if you will compile and execute the following c code?
#define message "union is\
power of c"
void main()
{
clrscr();
printf("%s",message);
getch();
}

union is power of c
 union is power of c
 union is Power of c
 Compiler error
None of these
SHOW ANSWER

What will be output if you will compile and execute the following c code?
void main(){
int a=25;
clrscr();
printf("%o %x",a,a);
getch();
}

25 25
025 0x25
 12 42
 31 19
 None of these
SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in