Learn c programming Online Test

main() { char a[4]="HELLO"; printf("%s",a); }
Compiler error: Too many initializers
some garbage value
syntax error
no out put
void main() { unsigned giveit=-1; int gotit; printf("%u",++giveit); printf("%u \n",gotit=--giveit); }
syntax
0
Compiler
00
main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }
syntax error
behaviour is implementation dependent
Compiler Error
no out put
#include main() { char s[]={'a','b','c','\n','c','\0'}; Char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }
77
88
compiler error
syntax error
main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }
syntax error
Compiler Error: switch expression not integral
some garbage value
no out put
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
2..4
syntax error
compiler error
4..2
main() { int i=10; i=!i>14; Printf ("i=%d",i); }
i=1
i=0
compiler error
syntax error
main() { int i=5; printf(“%d” , i=++i ==6); }
5
1
6
Compiler Error
main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++) { printf(" %d ",*p); ++p; } }
syntax error
compiler error
2 2 2 2 2 2 3 4 6 5
5 6 4 5 2 2 2 2
#include main() { struct xx { int x=3; Char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }
syntax error
no output
Compiler Error
Hello
main() { main(); }
syntax error
Runtime error : Stack overflow.
Compiler Error
print some address
/
Compiler Error
no out put
syntax error
garbage value
void main() { int k=ret(sizeof(float)); printf("\n here value is %d",++k); } int ret(int ret) { ret += 2.5; return(ret); }
Here value is 7
syntax error
Here value is 7.5
Compiler Error
main() { printf("%x",-1<<4); }
ffff
compiler error
fff0
0000
struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }
origin
Compiler error
originorgin
syntax error
main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }
556
655
565
555

void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }
syntax error
Ok here
Compiler Error
Forget it
#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
FALSE
TRUE
Compiler Error
syntax error
#define preprocessor command can be used for defining
macros
for loops
Symbolic constants
Both (1) and (2)

main() { int i=_l_abc(10) ; printf("%d\n",--i); } int _l_abc(int i) { return(i++); }
Compiler Error
11
10
9
/
first character of the string constant
complete string
address of the string storage
is a logical error
Consider the following variable declaration Union x{ int i; float f; char c; }y; if the size of i, f and c are 2 bytes, 4 bytes and 1 byte respectively then the size of the variable y is:-
1 byte
2 bytes
4 bytes
7 bytes
Pick up the odd one out from the following
x = x – 1
x - = 1
x - -
x = - 1
What is the value of ‘average’ after the following program is executed? main() { int sum, index ; sum = index = 0 ; float average; sum = 0; for( ; ; ) { sum = sum + index; ++index; if (sum >= 100) break ; } average = sum / index; }
91/13
91/14
105/14
105/15
Suppose i, j, k are integer variables with values 1, 2, 3 respectively. What is the value of the following expression? ! (( j + k ) > ( i + 5 ))
6
5
1
0
If a = -11 and b = -3. What is the value of a % b?
- 3
- 2
2
3
If c is a variable initialized to 1, how many times will the following loop be executed? while(( c > 0 && (c < 60))) { c++; }
61
60
59
1
Which one of the following describes correctly a static variable?
This cannot be initialized.
This is initialized once at the commencement of execution and cannot be changed at run time.
This retains its value through the life of the program.
This is same as an automatic variable but is placed at the head of a program.
What will be the output of the following program? main() { int a, *ptr, b, c; a = 25; ptr = &a; b = a + 30; c = *ptr; printf(“%d %d %d”, a, b, c); }
25, 25, 25
25, 55, 25
25, 25, 55
None of the above
If a = 0(aa and b = a << 1 then which of the following is true
b = a
b = 2a
a = 2b
b = a - 1
In a for loop with a multi statement loop body, semicolons should appear following:
the for statement itself
the crossing brace in the multiple statement loop body
each statement within the loop body and the test expression
each statement within the loop only
When we execute X++; the value of the expression X++ :
is equal to the original value of X
is one more than the original value of X
is X times more than the original value of X
none of the above
An Array’s name is a:
Pointer constant
Pointer variable
Variable name
None of the above
What is printed? for (i=1; i<=5; ) i++; printf(“%d”,i)
23456
12345
123456
error
Main() { int x = 0; while(x<=10) for( ; ; ) if( ++x%10 == 0 ) break; printf(“x = %d”, x) ; } What will be the output of the above program?
Will print x = 10
Will give compilation error
Will give runtime error
Will print x = 20
C uses pointers explicitly with
Arrays
Structures
Functions
All of the above
Which format specification is used in printf statement to print hexadecimal format
%i
%c
%x
%u
What will be the output of the following program: Main() { int val = 500; int *ptr = &val; int **ptr1 = &ptr; printf(“val = %d”, **ptr1); }
500
address of ptr
contents of ptr
none of the above
sizeof operator returns the size in bytes of
identifier
type
identifier or type
array
Which of the following is a valid octal constant?
32
032
049
0x49
Which of the following switch statement is not a valid statement to print “RED” if a character variable ‘color’ has the value ‘R’ or ‘r’?
What will be the output of the following code segment, if the function is called as larger(10, 20) ? int larger(int x, int y) { int max = x; if (max < y) { max = y; return y; } else return x; printf(“Larger of %d and %d is %d”, x, y, max); }
Program will not compile as the function has two return statements.
Program will not compile as no statement is allowed after return statement.
Larger of 10 and 20 is 20.
No output.
Given the code segment: char a[] = “abc”, *p; Which of the following assigns the starting address of the string “abc” to p?
p = a;
p = &a;
p = *a;
*p = a;
If an array is defined as static char a[10]; then the elements of a will be set to
an undetermined value
zero
blank character
character ‘~0’
Which of the following statement is false for the statement? main(int ac, char *av[])
av is an array of pointers to strings.
av[0] represents the name of the program under execution.
the formal arguments names have to be argc and argv only
the main function can return an integer to the calling function/program.
What will be the output of the following? main() { int a = ‘A’; printf(“%d”, a);
65
A
a
the program will not compile as an integer variable is assigned a character constant.
Description:

Concept of c programming

Discussion

kj

question 15 is wrong

3391 days 16 hours 4 minutes ago

Ram Bothe
M.C.M.
1 Follower
Tests: 2

Your Facebook Friends on WizIQ

More Tests By Author

c lang
39 Questions | 123 Attempts