CSC231: SMART TIPS FOR LEARNING COMPUTER PROGRAMMING WITH SUMMARY

By | August 24, 2019

MATERIAL ONE : WHAT YOU SHOULD KNOW

PART A

SMART TIPS FOR LEARNING COMPUTER PROGRAMMING WITH SUMMARY

 

1. # include <stdio.h> main() { inti=-3, j=2,k=0,m; m=++i || ++j && ++k; printf(“%d %d %d %d”, i,j,k,m); } What is the output of the code above?
A -4 2 1 0B. -2 2 0 1C. -2 1 0 1D. Compilation Error
2. There are how many character set in C language? A. 5 B. 6 C. 7 D. 4
3. What will be the final value of x in the expression (x+5)+ (x=x+5)+x, if x initially is 10?
A. 10 B. 15 C. 16 D.25
4. # include <stdio.h>main() { int m; float x, y; m=5; x=2.5; y = x*m; printf(“%d”,y); } What is the output of the code above?
A. 0.000000 B. 12.5 C. 12.500000 D. 0
5. # include <stdio.h> main() { float a,b,c; printf(“input value for a, b, and c”); scanf(“%f %f %f”,&a,&b,&c); printf(“%f”,(a > b ? (a >c ? a : c) : (b > c ? b : c ))); } What task is the code above solving?
A. Conditional OperatorB. Addition of three float variables
C. Display the largest of three input valuesD. Display the lowest of three input values
6. What is the output of the expression below. Let a= 6; x=x+ (a==’3′)*5-(x=5)/2)
A. 0 B. 15 C. 5 D. 10
7. What is the ASCII code for “\n” in C programming?
A. 0 B. 15 C. 10 D. 5
8. What is the ASCII code for “\0” in C programming ?
A. 5 B. 15 C. 10 D. 0
9. Which is the Odd out of the following?
A. _1234B. .ABC C. _____w D. A1234
10. Which of the following is not an attribute of a variable in C programming?
A. Memory Address B. Internal Address C. Scope D. Value
11. Which of the following is not true in C programming language?
A. C Language demands that all variables to be used in a program be declared before usage.
B. C uses dynamic binding C. No two variables in the same scope can have the same name
D. C is column sensitive
12. Which of the following is false about conversion characters?
A. Conversion character is a sequence of two characters which starts with %
B. Conversion character is an action character
C. Conversion character denotes a type into which the data for input or output is to be converted
D. Conversion characters are optional in scanf() and printf() functions
13. # include <stdio.h> main() { intx,y; scanf(“%d.%d”,&x,&y); printf(“%d %d”, x,y); } Output: 20 20 What set of values will be inputted to generated the output above?
A. 20 .20 B. 20 20 C. 20. 20 D. 20 . 20
14. # include <stdio.h> main() { int x=10, y=20, z=5, i; i = x < y < z ; printf(“%d”, i); } What is the output of the code above?
A. 0 B. 1 C. 2 D. 10
15. # include <stdio.h>main(){ int a = 8, b = 9; printf(“%d”, a=b); } What is the output of the code above?
A. 9 B. 8 C. 0 D. Compilation Error
16. # include <stdio.h>main(){ int a = 8, b = 9; printf(“%d”, a==b); } What is the output of the code above?
A. 9 B. 8 C. 0 D. Compilation Error
17. # include <stdio.h>main() { inti = 1; while() { printf(“%d”,i++); if (i>10) break; } } Point out the error, if any, in the while loop
A. No ErrorB. The condition in the while loop is a must
C. There should be atleast a semicolon in the while()D. The variable “i” is not valid in the scope
18. # include <stdio.h> main(){ inti=1; for( ; ; ){ printf(“%d”,i); if(i>10) break; } } Point out the error,if any, in the code above.
A. The conditional expression must always be in the appropriate place in the for loop
B. Semi colons in the for loop should be removedC. No error
D. The variable “i” is not valid in the scope
19. Assume variable x is stored at memory location 1000, y at memory 2000, and ip at memory 3000. What will be the value of ip after executing the following statements? int x, y, *ip; y=2; ip=&x;
A. ip = 3000B. ip = 2000C. ip = 1000D. ip = 2
20. What is the output of the code below? # include <stdio.h> main(){ int a=300, b=10, c=20 ; if(!(a>=400)) b=300; c=200; printf(“b = %d c = %d”,b,c); }
A. b = 300 c = 200B. b = 10 c = 200C. b=10 c=20D. b=300 c=200
21. What is the output of the code below? # include<stdio.h> main(){ int x=10, y=-20 ; x=!x; y=!y; printf(“x=%d y=%d”,x,y); }
A. x=0 y=0B. x=10 y=-20C. Garbage valueD. Compilation error
22. # include <stdio.h> # include <alloc.h> # include <stdlib.h> main() { char *sname ; sname=(char *)malloc(5); char fname[6]=(“hello”); sname=fname; free(sname); printf(“%s”,sname); } What is the output of the code above?
A. HelloB. Compilation ErrorC. Runtime TimeD. Garbage Value
23. What is the output of the code below? # include<stdio.h>main(){ int x=10, y=100%90 ; if(x!=y) printf(“x=%d y=%d”,x,y); }
A. x=10 y=10B. x=10 y=100C. x = 10 y = 10D. x = 10 y = 100
24. What is the value of x after executing the following program #include <stdio.h> #define x 5 intmain() { int *ptrx; ptrx = &x; *ptrx = 10; printf(“%d\n”, x); return 0; }
A.Compilation errorB. Runtime errorC.5D.10
25. # include <stdio.h> main(){ int a=500, b=100, c ; if(!a>=400) b=300; c=200; printf(“b = %d c = %d”,b,c); } What is the output of the code above?
A. b = 100 c = 200B. b=300 c=200C. b = 300 c = 200D. b=100 c=200
26. What is the output of the code below? # include<stdio.h> main(){ int x=0, y=1 ; y=!x; x=!y; printf(“x=%d y=%d”,x,y); }
A. x=0 y=1B. x=1 y=1C. x=1 y=0D. Compilation Error
27. Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What will be the value of y after executing the following statements? int x, y, *ip; x=1;y=2; ip=&x; y= *ip;
A. y = 1B. y = 2C. y = 100D. Runtimeerror
28. What is the output of the code below? # include <stdio.h> main() { intarr[] = {0,1,2,3,4} ; inti, *ptr; for (ptr = arr + 4, i = 0 ; i<= 4 ; i++) printf (“%d”, ptr[-1]); }
A. 4 3 2 1 0B. 43210C. 01234D. 0 1 2 3 4
29. What is the output of the code below? # include <stdio.h> main() { intarr[] = { 0,1,2,3,4} ; inti, *p; for (p = arr, i = 0 ; p + i<= arr + 4 ; p++, i++) printf (“%d “,*(p + i)) ; <br /> )}
A.01234B. 0 1 2 3 4C.024D.0 2 4
30. Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What will be the value of y after executing the following statements? int x, y, *ip1,*ip2; x=10;y=2; ip1=&x; ip2=&y; y= *ip1;
A. y = 100B. y = 1000C. y = 200D. y = 10
31. Assume variable x is stored at memory location 100, y at memory 200, and ip at memory 1000. What will be the value of y after executing the following statements? int x, y, *ip; x=1;y=2; ip=&y; y= *ip;
A. y = 2B. y = 1C. y = 100D. y = 200
32. What is the output of the code below? # include <stdio.h> main() { intarr[] = {0,1,2,3,4} ; inti, *ptr; for (ptr = arr + 4, i = 0 ; i<= 4 ; i++) printf (“%d”, ptr[-1]); }
A. 0 1 2 3 4B. 01234C. 43210D. 4 3 2 1 0
33. #include<stdio.h> void main() { int k=12, n=30; k=(k>5&&n=4?100:200); printf(“k=%d”,k); return 6;}
34. #include<stdio.h> void main(){ int x=10, y=20; if (!(!x)&&x)printf (“%d”, x); else printf(“%d”, y);};
35. #include<stdio.h> void main(){ int x=100; if (!!x) printf (“%d”, !x); else printf(“%d”, x);};
36. #include<stdio.h> void main(){ int x=0; if (x>3, x< 8) x++; printf(“%d”, x- -);;}
37. #include <stdio.h> main (){inti=4; switch(5) { default: puts(“ default section”);
Case 1: puts(“ statement of case 1”);
Case 2: puts(“ statement of case 2”);
Case 3: puts(“ statement of case 3 ”);
Case 4: puts(“ statement of case 4”);

READ:  ALL COURSES GUIDE LINE FOR ALL STUDENTS IN FACULTY OF PHYSICAL SCIENCES

 

 

CONTINUE READING ON THE NEXT PAGE

2 thoughts on “CSC231: SMART TIPS FOR LEARNING COMPUTER PROGRAMMING WITH SUMMARY

  1. Arowolo Aisha

    Really this is helpful in the actual sense but I’ll like it to be made simpler for a person like me
    I’m an ex-graduate tho not in this faculty but I’ve developed a personal interest in computer programming language and i thought this material could help but I’m afraid it’s not getting me anywhere

    Pls do more help

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *