Test on C Programming Fundamentals Part 2 August 3, 2019 thomas 1. What is the output of following code ? #include<stdio.h> void main() { int i=0; do { printf(“inside the loop\n”); } while(i==1); printf(“outside the loop\n”); } inside the loop outside the loop outside the loop inside the loop inside the loop outside the loop 2. Will loop execute? #include<stdio.h> void main() { Int i; for( ; i ; ) printf(“%d”,i); printf(“outside the loop\n”); } loop execute inifinitly outside the loop inside the loop %d 3. Generate the output? #include<stdio.h> void main() { int i; for(i=0;i<10;i++) { printf(“%d,”,i); if(i==5) continue; if(i==7) break; } } 0,1,2,3,4,5,6,7 0,1.3,4,6,7,8 0,1,2,3,4,6,7,9 1,2,3,4,5,6,7,8 4. What is the output #include<stdio.h> void main() { int a[10]; printf(“%d”,sizeof(a)); } 44 42 41 40 5. #include<stdio.h> void main() { int i; while(1) { printf(“there is no loop”); } } error display “there is no loop” infinitly. loop will not excute there is no loop 6. Give an example exit controlled loop? while do while if if else 7. Give an example of entry control loop? while ,if while , do while while , for for ,do while 8. What will be the output? main() { int i; for(i=1;i<=5;printf(“\n%d”,i)); i++; } 1,2,3,4,5 infinite 1,2,5 5,4,3,2,1 9. main() { Int p; for(p=1;p<=10,–p;p=p+2) printf(“hello\n”); printf(“hai”); } hai hai hai hai hai hai error 10. Name the function that calls itself? recursive function by the name given by user inline function main function 11. Single line swapping can be done using which of the below expression: b = a = b; b = a+b-(a=b); a = b = a; a = a+b-(a=b); 12. What are the methods to declare an array as an argument? return_type function(type array name[] ) return_type function(type array name[SIZE]) return_type function(type*array.name) return_type function(type array name all 1,3,4 1,2,3 none 13. What is the right way to initialize int num[6]={1,2,4,6,7,8}; int n{} = {2,3,4,5,3] int f={4,5,6,7,8} int a(2)={3,4,7,8} 1 2 3 4 14. Find the output of the following program : #include<stdio.h> void main() { int f = 2; while(f!=31.0) { printf(“%f\n”,f); f +=0.1; } } 2 2.1 2.2 infinite 15. Syntax for the 2D Array int twodimen[4][3]; int 2D[4,3] int twodimen[[4][3] int [3][5] 16. #include<stdio.h> int main() { int x,y; for(x=5;x>=1;x – -) { for(y=1;y>=x;y++) printf(“%d\n”,y); } } infinite 5 4 3 17. What is the output main() { char a[]=”a b c”; char b[]= “a b c”; int i; printf(“%d\n”,strcmp(a,b)); } 0 1 2 3 18. Find the true statement given below: #inlcude<stdio.h> void main() { char c; printf(“enter a character”); scanf(“%c”,&c); printf(“%c = %d”,c,c); } prints the ASCII value of the character nothing will output can’t assign a inter value to character value none of the above 19. What will happen? #include<stdio.h> main() { char a[]=”kutty mama njan njetty mama”; printf(“%d\n”,strlen(a)); } 23 27 22 24 20. What will happen main() { char a[]=”racecar”; printf(“%s\n”,strrev(a)); } carracer carrace racecar racicar 21. What will print on the output screen? #include<stdio.h> void main() { int i,j,a[2][2]={{1,2},{2,1}},x; for(i=0;i<2;i++) for(j=0:j<2:j++) { if(x=i==j) printf(“%d\t”,a[i][j]); } } 2 2 1 1 0 0 none of the above 22. What is the output ? #include<stdio.h> int f(int); void main() { int b; b=f(20); printf(“%d”,b); } int f(int a); { return a = a>20 ? 10 : 20; } 10 20 0 none of the above 23. What will be the output ? #include<stdio.h> main() { int a[3][4]={{1,2,3},{4,5,6},{7,8,9}}; printf(“%d”),a[2][3]; } 0 6 9 1 24. what will be the output main() { char str1[]=”abcd”; char str2[]=”efgh”; printf(“%d %d”,sizeof(str1),sizeof(str2)); } 5 5 4 4 5 4 4 5 25. what will be the output ? main() { char s[20]=”hello world”; s[5]=’\0’; printf(“%d”,strlen(s)); } 4 5 0 none of the above 26. what are the true statements? main() { printf(“oh my god”); main(); } Main function execute inifintly Example of recursion Logical error Can’t call main function within main function 27. find the true statements for the below program main() { char s[]=”’\0’super ball” printf(“%s”,s); } nothing will print “super ball will print” ‘ will print none of the above 28. how to declare character array in c ? int a[15] int a[15]; char str[15]; char str[15] 29. how to declare 2-D integer array in c ? int a[2][2] int a[2][2]; float [4][3] int a[2][2]={{1,2},{2,1}}; 30. How we can call a subroutine? function_name(); variable = function_name(); function_name(c); c.function_name(); Loading … Question 1 of 30