Sei sulla pagina 1di 10

Problem Solving and C

EMPLOYEE NAME : MARKS:

EMPLOYEE NO : DURATION:

Question-1:
#include<stdio.h>
Void main()
{
Int a, b, c , k
a=5;
b=2;
c=3;
k = ((a * b) + c) (2.5 * a + b);
printf(“%d”, k);
}
Output:
a) 227
b) 227.5
c) No output
d) Error

Question-2:
#include<stdio.h>
Void main()
{
Int a, b;
a=b=3=4;
printf(“%d”, a+b);
}
Output:
a) 7
b) 3
c) 4
d) Error

@NIIT ALL THE BEST!!! 1 of 10


Problem Solving and C

Question-3:
#include<stdio.h>
Void main()
{
float a=5, b=2;
int c;
c = a % b;
printf(“%d”, c);
}
Output:
a) 2.5
b) 1
c) 2
d) error

Question-4:
#include<stdio.h>
void main()
{
int a;
a = 30 * 1000 + 2768;
printf(“%d”, a);
}
Output:
a) 32768

b) -32768

c) 113040

d) 0

Question-5:
#include<stdio.h>
void main()
{
int k = 35;
printf(“%d%d%d”, k ==35, k = 50, k > 40);
}

@NIIT ALL THE BEST!!! 2 of 10


Problem Solving and C

Output:
a) 0 50 0

b) 1 50 1

c) 1 50 0

d) 0 50 1

Question-6:

#include<stdio.h>
void main()
{
int a = 5, b, c;
b = a = 15;
c = a < 15;
printf(“\na = %d b = %d c = %d”, a, b, c);
}

Output:
a) a =15 b = 15 c = 0

b) a = 5 b = 15 c = 0

c) a = 15 b = 15 c = 1

d) a = 5 b = 15 c = 1

Question-7:

#include<stdio.h>
void main()
{
float a = 12.25, b = 12.52
if(a = b)
printf(“a and b are equal);
}

above code will give output (TRUE/FALSE)

@NIIT ALL THE BEST!!! 3 of 10


Problem Solving and C

Question-8:

#include<stdio.h>
void main()
{
int x = 2
if(x ==2 & x != 0);
{
printf(“hi”);
}
else
printf(“bye”);
}

Output:
a) hi

b) bye

c) error

d) hi bye

Question-9:

#include<stdio.h>
void main()
{
int x= 4, y, z;
y = --x;
z = x--;
printf(“%d%d%d”, x, y, z);
}

Output:
a) 4 3 4

b) 2 3 3

c) 4 3 3

d) 2 3 4

@NIIT ALL THE BEST!!! 4 of 10


Problem Solving and C

Question-10:

#include<stdio.h>
void main()
{
int i;
while (i = 10)
{
printf(“%d”, i);
i = i + 1;
}
}

Output:
a) 1 to 10 will be printed

b) 0 to 9 will be printed

c) error

d) infinite loop

Question-11:

If a file is opened for reading it is necessary that the file must exist (TRUE/FALSE)

Question-12:

If a file opened for writing already exists its content would be overwritten
(TRUE/FALSE)

Question-13:

For opening a file in append mode it is necessary that the file should exist
(TRUE/FALSE) // not sure :-)

Question-14:

We can send arguments at command line even if we define main() function without
parameters (TRUE/FALSE) // not sure :-)

@NIIT ALL THE BEST!!! 5 of 10


Problem Solving and C

Question-15:

To use standard file pointer we don’t need to open the file using fopen()
(TRUE/FALSE)

Question-16:

Using stdaux we can send output to the printer if printer is attached to the serial port
(TRUE/FALSE)

Question-17:

#include<stdio.h>
void main()
{
int i =3, j =4, k ,l;
k = addmult(i, j);
l = addmult(i,j);
printf(“%d%d”, k, l)
}
addmult( int ii, int jj)
{
int kk, ll;
kk = ii + jj;
ll = ii + jj;
return( kk, ll);
}
Output:
a) 7 7

b) 7 4

c) 3 7

d) error

Question-18:

#include<stdio.h>
void main()
{
float a = 15.5;
char ch = ‘C’;
printit(a, ch);
@NIIT ALL THE BEST!!! 6 of 10
Problem Solving and C

printit(a, ch)
{
printf(“%f%c”, a, ch);
}

Output:
a) 15.5 C

b) 15 C

c) infinite loop

d) error

Question-19:

What would be the output of the following program?


main()
{
int a = 300, b, c;
if (a >= 400)
b = 300;
c = 200;
printf (“\n%d%d”,b,c);
}

Output:

a) Compilation Error
b) b will contain some garbage value and c will be equal to 200
c) b will be equal to 300 and c will return some garbage value.
d) b and c will return garbage values

@NIIT ALL THE BEST!!! 7 of 10


Problem Solving and C

Question-20:

The difference between the concept of structures and unions in C language is in terms of

Output:

a) speed
b) storage
c) Both 1 and 2
d) None of the above

Question-21:

Array of structure is

Output:
a) An array in which each element is a structure
b) A Structure in which each element is an array
c) Both 1 and 2
d) None of the above

Question-22:

What is the output of the following program?


main()
{
     int a=10,b=25;
      a=b++ + a++;
      b= ++b + ++a;
      printf(“%d%dn”,a,b);
}
Output:
a)35 65
b)36 64
c) 37 64 // plz help to explain this 
d) 34 64

@NIIT ALL THE BEST!!! 8 of 10


Problem Solving and C

Question-23:

The notation for preprocessor directive is


Output:
a) $
b) !
c) @
d) #

Question-24:

What does the following C program results?


main()
{
   int exforsys=100;
   int test[exforsys];
   for(j=1;j<=exfosys;j++)
{
     scanf("%d",&exforsys[j]);
}
}

Output:
a) prints array element
b) takes array elements as input from user
c) gives error
d) none of the above

@NIIT ALL THE BEST!!! 9 of 10


Problem Solving and C

Question-25:

Point out the errors, if any, in the following programs:


main()
{
int j = 10, k = 12;
if ( k >= j)
{
{
k = j;
j = k;
}
}
}
Output:
a) No Error. Any number of pairs of braces can be used.
b) Error. Only one pair of braces can be used.
c) No error. Values of j and k will be returned.
d) None of the above.

@NIIT ALL THE BEST!!! 10 of 10

Potrebbero piacerti anche