Вы находитесь на странице: 1из 5

C Test

Assessment 1 Questions

Duration – 30 minutes Marks 20 * 1 = 20

1. What is the output of the following code ?

void main()
{
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf("EXAM");
}
}

1) XAM is printed
2) exam is printed
3) Compiler Error
4) Nothing is printed

2. What is the output of the following code?

#include<stdio.h>
void main()
{
int s=0;
while(s++<10)
{
if(s<4 && s<9)
continue;
printf("\n%d\t",s);
}
}

1) 1 2 3 4 5 6 7 8 9
2) 1 2 3 10
3) 4 5 6 7 8 9 10
4) 4 5 6 7 8 9

3. Array passed as an argument to a function is interpreted as

1) Address of the array


2) Values of the first elements of the array
3) Address of the first element of the array
4) Number of element of the array
C Test

4. What is the output of the above program code?

#include <stdio.h>
void main()
{
int i=3,*j,**k;
j=&i;
k=&j;
printf("%d%d%d",*j,**k,*(*k));
}

1) 444
2) 000
3) 333
4) 433

5. Which of the following is the correct way of declaring a float pointer:

1) float ptr;
2) float *ptr;
3) *float ptr;
4) None of the above

6. What is the output of this program?

main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
1) program will not compile
2) 10
3) god only knows
4) address of I

7. What is the output of the following code?

#include<stdio.h>
void swap(int&, int&);
C Test

void main()
{
int a = 10,b=20;
swap (a++,b++);
printf("\n%d\t%d\t",a, b);
}
void swap(int& x, int& y)
{
x+=2;
y+=3;
}

1) 14, 24
2) 11, 21
3) 10, 20
4) Error

8. What is the output of the following code?

#include<stdio.h>
void main()
{
int a=0,b=0;
a = (b = 75) + 9;
printf("\n%d, %d",a, b);
}
1) 75, 9
2) 75, 84
3) 84, 75
4) None of these options

9. What is the output of the following code?

# include<stdio.h>
# define a 10
main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}
C Test

1) 10..10
2) 10..50
3) Error
4) 0

10. What is the output of this program?

main()
{
char thought[2][30]={"Don`t walk in front of me..","I am not follow"};
printf("%c%c",*(thought[0]+9),*(*(thought+0)+5));
}

1) k k
2) Don`t walk in front of me
3) I may not follow
4) K

11. The reason for using pointer is ...


Choose the false option from the following sentences

1) Accessing arrays or string elements


2) Dynamic memory allocation
3) Implementing linked list,trees,graphs and many other data structures
4) All are false

12. The size of a structure can be determined by

a. size of variable name


b. size of (struct tag)

1) Only a
2) Only b
3) Both a and b
4) None of these options

13. Notate the following class attributes :


a. public + (plus sign)
b.protected # (hash symbol)
c. private - (minus sign)
d.derived / (forward slash)
14. char* myFunc (char *ptr) {
ptr += 3;
return (ptr);
}
int main() {
char *x, *y;
C Test

x = "HELLO";
y = myFunc (x);
printf ("y = %s \n", y);
return 0;
}
15. What will print when the sample code above is executed?

e. y = HELLO
f. y = ELLO
g. y = LLO
h. y = LO
i. x=O
16. scanf function revives 2 parameter
j. formatted string and variables separated by comma
k. formatted string and address of variables separated by comma
l. a and b both are true
m. a and b both are false

Вам также может понравиться