Objectives

C Objective Questions 8

152. What is the output? void main() { int a; a=100; printf(“%d %d”,++a,++a); } 153. What is the output? void main() { int i=-1; +i; printf(“i = %d, +i = %d \n”,i,+i); } 154. Which of the following is not a valid operator? A) + B)++ C)+++ D)+= 155. Which of the following daa type cannot be used with operator %? A) char B)double C)float D) Both B and C Attend Free Demo and Learn   C LANGUAGE ONLINE TRAINING   by Real-Time Expert 156. What is the output of the following code? void main() { int x = 10; const int y = x; x = x + 2; printf(“%d [...]

Read more...
C Langauge Practice Programs-MCQs-Objective-Questions

C Objective Questions 7

95. What is the output of the following program? void main() { int i = 2, j = 3, k, l; float a,b; k = i / j * j; l = j / i * i; a = i / j * j; b = j / i * i; printf(“%d %d %f %f \n” , k,l , a,b); } 96. What is the output of the following code? void main() { int a=5; int x; x = ++++a; printf(“%d %d”, a,b); } 97. What is the output of the following code? void main() { int a = 97; printf(“%d %u [...]

Read more...
C Langauge Practice Programs-MCQs-Objective-Questions

C Online Test 6

32. What is the output of the following code? void main() { int a = 010; printf(“\n a = %d “, a); } 33. What is the output of the following code? void main() { int a = 010; printf(“\n a = %o “, a); } 34. What is the output of the following code? void main() { int a = 53; printf(“\n a = %o “, a); } 35. What is the output of the following code? void main() { int a = 53; printf(“\n a = %x “, a); } Attend Free Demo and Learn   C LANGUAGE ONLINE TRAINING   by [...]

Read more...
C Langauge Practice Programs-MCQs-Objective-Questions

C Online Test 5

1. What is the output of the following code? void main() { int x; x = 3 > 2 > 1; printf(“%d” , x); } 2. What is the output of the following code? void main() { printf(“%X” , -1<<4); } 3. What is the output of the following code? void main() { int c = – -2; printf(“c=%d”,c); } 4. What is the output of the following code? void main() { int i=5; printf(“%d%d%d%d%d” , i++,i–,++i,–i, i); } 5. What is the output of the following code? void main() { int i; printf(“%d” , scanf(“%d”,&i)); // value 10 is given as input here } Attend Free Demo and [...]

Read more...

C Language Online Test 4

What is the output? #include <stdio.h> void main() { int a[] = {10,12,6,7,2}; int i,sum=0; for(i=0; i<5; i++) { sum = sum + *(a+i); } printf(“%d\n”, sum); } Ans: Sum of array elements What is the output? int main() { int val = 5; int* ptr = &val; printf(“%d %d”,val,(*ptr)++); return 0; } Ans: 6 5 What is the output? void main() { int arr[ ] = {10,20,30,40,50,60,70}; int *i, *j; i = &arr[1]; j = &arr[5]; printf(“%u \n” , j – i ); printf(“%d \n” , *j – *i ); } Ans: 4 40 What is the output? int main(void) { int x = 5; int *p1, *p2; p1 = &x; p2 = p1; printf(“%u”,p2); return 0; } Ans: Address of [...]

Read more...

C Language Online Test 3

what is the output? int main() { int a[100]; int sum = 0; int k; for(k=0; k<100; k++) { *(a+k) = k; } printf(“%d”,a[–k]); return 0; } Ans: 99 What is the output? void main() { int i=5; int *p; p = &i; printf(”The value of i is : %d \n”,*p); *p = *p + 10; printf(”The value of i is : %d \n”, *p); } A: 5 15 What is the output? void main() { int a = 5; double b = 3.1415; void *vp; vp = &a; printf(“a=%d\n”, *((int *)vp)); vp=&b; printf(“b=%lf\n”,*((double *)vp)); } Ans: 5     3.1415 What is the output? int main () { int *p; p = NULL; printf(“ \n The value of p is %d \n” [...]

Read more...

C Language Practice Programs 2

What is the output? #include <stdio.h> void main() { int a[2][3]={0,1,2,3,4,5}; printf(“%d”,sizeof(a[2])); } Ans:  6 or 12 What will be the output of the following program code? #include <stdio.h> void main() { int i=3, *j, **k; j = &i; k = &j; printf(“%d%d%d”, *j, **k, *(*k)); } 444 000 333 433 Ans: 3 What is the output? #include <stdio.h> void main() { int a[]={1,2,3,4,5,6}; int* ptr = a + 2; printf(“%d”,*–ptr); } Ans: 2 Find the output of the following program. void main() { int array[10]; int *i = &array[2], *j = &array[5]; int diff = j-i; printf(“%d”, diff); } 3 6 Garbage value Error Ans: 3 What is the output? #include <stdio.h> void main() { int a[5]={1,3,6,7,0}; int* b; b = &a[2]; printf(“%d”,b[-1]); } Ans: 3 Attend Free Demo and Learn   [...]

Read more...

C Language Practice Programs 1

Determine output: #include <stdio.h> void main() { char *p = NULL; char *q = 0; if(p) printf(” p “); else printf(“nullp”); if(q) printf(“q”); else printf(” nullq”); } p q Depends on the compiler x nullq where x can be p or nullp depending on the value of NULL nullp nullq Ans: 4  What is the output? #include <stdio.h> void main() { printf(“Hi Friends”+3); } Output: Friends  The address operator &, cannot act on Constants Arithmetic expressions Both of the above Local variables Ans: 3 What is the output? #include <stdio.h> void main() { int a[][3]={0,1,2,3,4,5}; printf(“%d”,sizeof(a)); } Ans: 12 or 24 #include<stdio.h> void main() { int *ptr, a=10; ptr = &a; *ptr += 1; printf(“%d, %d”, *ptr, a); } 10, 10 10, 11 11, 10 11, 11 Ans: 4 Attend Free Demo and [...]

Read more...