Você está na página 1de 2

Session : 6 C programming Workshop Name:______________ User

ID_________________

1. Which of the following correctly declares 8. What will be the output of the following code
an array? strip?
A. int anarray[10]; B. int anarray; for(i=0;i<5;i++)
for(j=0;j<1;j++)
C. anarray{10}; D. array anarray[10];
printf(a);
2. What is the index number of the last
A. aaaaa B. aaaa
element of an array with 29 elements? C. aaaa D. aaaaaaaaaa
A. 29 B. 28
C. 0 D. Programmer-defined 9. What will be the value of s?
3. Which of the following statement is int s=0;
correct? for(i=1;i<5;i++)
A. All array elements are of same type. s+=i;
B. An array will have default value zero.
C. An array can always be integer. A. 6 B. 15
D. None of the above. C. 10 D. None of the option
4. What will be the output of the following
code 10. What will be the output of the following code
main() #include<stdio.h>
{ int main()
int a[10] ={1,2,3}; {
printf(%d,a[5]); int a = 500, b = 100, c;
} if(!a >= 400)
A. 0 B. error b = 300;
C. garbage value D. 1 c = 200;
5. What will be the output of the following printf("b = %d c = %d\n", b, c);
code return 0;
main() }
{
int a[10] ={1,2,3}; A. b = 300 c = 200
printf(%d,a[0]); B. b = 100 c = garbage
} C. b = 300 c = garbage
A. 0 B. error D. b = 100 c = 200
C. garbage value D. 1
11. What will be the output of the following code
6. What is the size of an array int main()
main() {
{ int s=0,n=12;
int a[] ={1,2,3}; while(n!=0)
} {
A. 0 B. 3 s=s+n%10;
C. 2 D. error in code n/=10;
}
7. If an array is declared as, int a[7],what is printf(%d, s);
its size in the memory? }
A. 7 B. 6
C. 14 D. 12 A. 0 B. 3 C. 12 D. NONE

12. What will be the output of the following code?


int main()
{
int i=10;
if(i%2==0)
{ return 0;
break; }
printf(odd); A. 1 B. 10
} C. 0 D. 6
else 17. What is the output of the following code
{ #include<stdio.h>
printf(EVEN); int main()
{
}
float arr[] = {12.4,2.3,4.5,6.7};
A. odd B. EVEN printf("%d\n", sizeof(arr)/sizeof(arr[0]));
C. break; D. Error return 0;
13. What is the output of the following code: }
int main() A. 5 B. 4
{ C. 6 D. 7
int numbers[]={1,2,3,4,5}; 18. What is the output of the following code
int i=0;
int i;
for(; i<=5; i++);
for(i=0;i<3;i++); printf("%d", i);
printf("%d ",numbers[i]); A. 0, 1, 2, 3, 4, 5 B. 5
return 0; C. 1, 2, 3, 4 D. 6
} 19. What is the error in the code
A. 1 2 3 4 5 B. 1 2 3 4 #include<stdio.h>
C.4 D. 5 int main()
{
14. Which of the following statement is correct?
int a = 10;
A. In C the array boundaries are checked by the switch(a)
compiler. {
B. In array the array name is the base address. }
C. Array can store all the data of same type. printf("This is c program.");
D. All are correct return 0;
15. What is the output of the following code? }
A. Error: No case statement specified
#include<stdio.h>
B. Error: No default specified
C. No Error
int main()
D. Error: infinite loop occurs
{
20. What is the error in the following code
int arr[5], i=0;
#include<stdio.h>
while(i<5)
int main()
arr[i]=++i;
{
int i=1;
for(i=0; i<5; i++)
while()
printf("%d, ", arr[i]);
{
printf("%d\n", i++);
return 0;
if(i>10)
}
break;
A. 1, 2, 3, 4, 5, B. Garbage value, 1, 2, 3, 4,
}
C. 0, 1, 2, 3, 4, D. 2, 3, 4, 5, 6
return 0;
16. What is the output of the following code
}
#include<stdio.h>

A. There should be a condition in the while loop


int main()
B. There should be at least a semicolon in the while
{
C. The while loop should be replaced with for loop.
int arr[1]={10};
D. No error
printf("%d\n", 0[arr]);

Você também pode gostar