Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Computer Science ATP (X)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Page 1 of 12

aGhulaman-e-Abbas School
Alternate to Practical (ATP)
Computer Science (Class: X)
1. What will be the output of the following 4. What is the output of C program with
program? #define?
#include <stdio.h> #define C 156
main(){
main()
int x, y, z ; {
x = 18, y =3.5 ; int a=10;
z = x\y ; a = a*C;
printf(“\n z=%d ”, z); printf("C=%d",a);
}
}
A. Z=6
A. 0
B. A=0 B. 1560
C. Error C. 1560
D. 6.5 D. Compiler error

2. What will be the output of the following 5. What is the output?


program? main()
#include <stdio.h> {
Main(){ float c = 3.5 + 4.5;
printf("%f", c);
int a;
return 0;
float b, c ;
}
b = 7.5 , c = 5.2 , a = a + b ;
printf(“\n a=%f”,a); } A. 8.0
B. 8.000000
A. 12.7 C. 8
B. 12 D. 7
C. 13.5
D. Error 6. Choose a right statement.
int main()
3. Read the following C codes: {
float c = 3.5 + 4.5;
float a = 5/2;
printf("%d", (int)c);
float b = 5/2.0;
return 0;
float c = 5.0/2;
}
float d = 5.0/2.0;
A. 8.0
Choose a right statement.
B. 8.000000
A. a=2.5, b=2.5, c=2.5, d=2.5 C. 7
B. a=2, b=2.5, c=2.5, d=2.5 D. 8
C. a=2.0, b=2.5, c=2.5, d=2.5
D. a=2.0, b=2.0, c=2.0, d=2.0

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)


Page 2 of 12

7. Choose a right statement. 11. What will be the output of the following
program?
int main()
{ #include <stdio.h>
int var = 3.5;; main(){
printf("%f", var); int x, y, z ;
return 0; x = 18, y =3.5 ;
} z = x\y ;
A. 3.500000 printf(“\n z=%d ”, z);
B. 3 }
C. 3.5
D. 0.000000 A. Z=6
B. A=0
8. What is the output of the program? C. Error
D. 6.5
int main()
{
int a = 25%10; 12. What will be the output of the following C
printf("%d", a); code?
}
#include <stdio.h>
A. 2.5 Int main()
B. 2 {
C. 5 float f1 =0.1;
D. Compiler error. if(f1 ==0.1)
printf("equal\n");
9. What is the output of the program? else
printf("not equal\n");
int main() }
{
float a = 45; A. Equal
printf("%f", a); B. not equal
return 0; C. output depends on the compiler
} D. error
A. 45 13. What will be the output of the following C
B. 45.0 code?
C. 45.000000
D. 0.000000 #include <stdio.h>
Intmain()
10. All keywords in C are in : {
A. LowerCase letters float x ='a';
B. UpperCase letters printf("%f", x);
C. CamelCase letters return0;
D. None of the mentioned }

A. A
B. run time error
C. a.0000000
D. 97.000000

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)


Page 3 of 12

14. What will be the output of the following C 17. What will be the output of the C code?
code?
#include <stdio.h>
#include <stdio.h> int main()
#define a 10 {
in tmain() j =10;
{ printf("%d\n",j++);
constint a =5; return0;
printf("a = %d\n", a); }
}
A. 10
B. 11
A. a=5
C. Compile time error
B. a = 10
D. 0
C. Compilation error
D. Runtime error
18. What will be the output of the C code?
15. What will be the output of the following #include <stdio.h>
C program? int main()
{
#include <stdio.h>
inti=-3;
int main()
int k =i%2;
{
printf("%d\n", k);
constint p;
}
p =4;
printf("p is %d", p);
A. Compile time error
return0;
B. -1
}
C. 1
D. Implementation defined
A. p is 4
B. Compile time error 19. What will be the output of the C code?
C. Run time error
#include <stdio.h>
D. p is followed by a garbage value
int main()
{
16. What will be the output of the C code?
inti=5;
#include <stdio.h> i=i/3;
int main() printf("%d\n",i);
{ return0;
intconst k =5; }
k++;
printf("k is %d", k); A. Implementation defined
} B. 1
C. 3
A. k is 6 D. Compile time error
B. Error due to const succeeding int
C. Error, because a constant variable can
be changed only twice
D. Error, because a constant variable
cannot be changed

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)


Page 4 of 12

20. What will be the final value of x in the 23. What will be the output of the following C
following C code? code?
#include <stdio.h> #include <stdio.h>
main(){ void main()
int x =5*9/3+9; {
} int k =4;
float k =4;
A. 3.75 printf("%d", k)
B. Depends on compiler }
C. 24
D. 3 A. Compile time error
B. 4
21. What will be the output of the following C C. 4.0000000
code? D. 4.4
#include <stdio.h>
int main() 24. What will be the output of the following C
{ code?
int a =10;
#include <stdio.h>
double b =5.6;
int main()
int c;
{
c = a + b;
inti=-3;
printf("%d", c);
int k =i%2;
}
printf("%d\n", k);
}
A. 15
B. 16
C. 15.6 A. Compile time error
D. 10 B. -1
C. 1
22. What will be the output of the following C D. Implementation defined
code?
#include <stdio.h> 25. What will be the output of the following
int main() C code?
{ #include <stdio.h>
int a =10, b =5, c =5; int main(){
int d; int i=3;
d = a ==(b + c); int j =i/-2;
printf("%d", d); int k =i% -2;
} printf("%d %d\n", j, k);
return0;
A. Syntax error }
B. 1
C. 10 A. Compile time error
D. 5 B. -1 1
C. 1 -1
D. Implementation defined

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)


Page 5 of 12

26. What will be the output of the following C 29. What will be the output of the following C
code? code?
#include <stdio.h> #include <stdio.h>
int main() void main()
{ {
inti=5; int x =5.3%2;
i=i/3; printf("Value of x is %d", x);
printf("%d\n",i); }
return0;
} A. Value of x is 2.3
B. Value of x is 1
A. Implementation defined C. Value of x is 0.3
B. 1 D. Compile time error
C. 3
D. Compile time error
30. What will be the output of the following C
code?
27. What will be the output of the following C
#include <stdio.h>
code?
main()
#include <stdio.h> {
int main() int y =3;
{ int x =5%2*3/2;
inti=-5; printf("Value of x is %d", x);
i=i/3; }
printf("%d\n",i);
return0; A. Value of x is 1
} B. Value of x is 2
C. Value of x is 3
A. Implementation defined D. Compile time error
B. -1
C. -3
31. What will be the output of the following C
D. Compile time error
code?
28. What will be the final value of x in the #include <stdio.h>
following C code? void main()
{
#include <stdio.h>
int a =3;
void main()
int b =(++a) + (a++) + (--a);
{
printf("Value of b is %d", b);
int x =5*9/3+9;
}
}
A. Value of x is 10
A. 3.75
B. Value of x is 11
B. Depends on compiler
C. Value of x is 12
C. 24
D. Value of x is 13
D. 3

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)


Page 6 of 12

32. What will be the output of the following C 35. What will be the output of the following C
code? code?
#include <stdio.h> #include <stdio.h>
int main() int main()
{ {
int a =10; int a =1, b =1, c;
double b =5.6; c = a++ + b;
int c; printf("%d, %d %d", a, b, c);
c = a + b; }
printf("%d", c);
} A. a = 1, b = 1, c = 2
B. a = 2, b = 1, c = 2
A. 15 C. a = 1, b = 2, c = 3
B. 16 D. a = 2, b = 2, c = 3
C. 15.6
D. 10
36. What will be the output of the following C
33. What will be the output of the following C code?
code?
#include <stdio.h>
#include <stdio.h> int main()
void main() {
{ int a =1, b =1, c =1;
int x =1, y =0, z =5; printf("%d, %d, %d",a++, ++b, c--);
int a = x && y || z++; }
printf("%d %d", z, a);
} A. a = 2, b = 12, c = 1
B. a = 2, b = 02, c = 1
A. z = 5 , a = 0 C. a = 1, b = 2 , c = 2
B. z = 6 , a = 1 D. a = 1, b = 2 , c = 1
C. z = 0 , a = 1
D. z = 1 , a = 1 37. What will be the output of the following C
code?
34. What will be the output of the following C
#include <stdio.h>
code?
int main()
#include <stdio.h> {
void main() int a =10, b =10;
{ if(a =5)
int x =97; b--;
char y = x; printf("%d, %d", a, b--);
printf("%c", y); }
}
A. a = 10, b = 9
A. a B. a = 10, b = 8
B. b C. a = 5, b = 9
C. 97 D. a = 5, b = 8
D. Run time error

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)


Page 7 of 12

38. What will be the output of the following C 41. What will be the output of the following C
code? code?
#include <stdio.h> #include <stdio.h>
int main() int main(){
{ int x =5;
Int I = 0; if(x <1)
int j = i++ + i; printf("Kello");
printf("%d\n", j); if(x ==5)
} printf("Hi");
else
A. 0 printf("No");
B. 1 }
C. 2
D. Compile time error A. Hi
B. Hello
39. What will be the output of the following C C. No
code? D. Error
#include <stdio.h>
42. What will be the output of the following C
int main()
code?
{
inti=2; #include <stdio.h>
int j =++i+i; int main(){
printf("%d\n", j); int x =5;
} if(x <1);
printf("Hello");
A. 6 }
B. 5
C. 4 A. Nothing
D. Compile time error B. Run time error
C. Hello
40. What will be the output of the following C D. Varies
code?
43. What will be the output of the following C
#include <stdio.h>
code?
int main()
{ #include <stdio.h>
int x =0; int main(){
if(x =0) int x =1;
printf("Its zero\n"); if(x >0)
else printf("inside if\n");
printf("Its not zero\n"); elseif(x >0)
} printf("inside elseif\n");
}
A. Its not zero
B. Its zero A. inside if
C. Run time error B. inside elseif
D. None C. inside if inside elseif
D. compile time error

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)


Page 8 of 12

44. What will be the output of the following C 47. What is the output of c program with %*
code? (Assuming that we have entered the operator? (input = GH)
value 1 in the standard input)
int main()
#include <stdio.h> {
int main(){ char kh;
double ch; scanf("%*c %c",&kh);
printf("enter a value between 1 -2"); putchar(kh);
scanf("%lf",&ch); return 0;
switch(ch) }
{
A. G
case1:
B. H
printf("1");
C. A
break;
D. Compiler error
case2:
printf("2");
48. What is the output of the C statement?
break;
} } int main()
{
A. Compile time error int a=0;
B. 1
a = 5<2 ?4 : 3;
C. 2
D. None printf("%d",a);
}
45. What is the output of C program?
A. 4
B. 3
int main(){ C. 5
int a=123456; D. 2
printf("*%3d*",a);
} 49. What is the output of the C Program?
A. *123* int main()
B. *6123* {
C. *123456* if( 4> 5 )
D. *012345* {
printf("Yes \n");
46. What is the output of C program in input }
value is ‘S’? printf("No");
return 0;
int main(){
}
char ch='A';
ch=getchar(); A. No
putchar(ch); B. Yes No
} C. No Yes
D. Compiler error
A. A
B. B
C. S
D. Compiler error

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)


Page 9 of 12

53. What is the output of C Program with


Switch Statement?
50. What is the output of C Program.?
int main(){
int main(){
int a=5;
int a=5;
switch(a)
while(a==5)
{
{
case 0: printf("0 ");
printf("HELLO");
case 3: printf("3 ");
}
case 5: printf("5 ");
return 0;
default: printf("END ");
}
}
A. HELLO is printed unlimited number of
a=10;
times
B. HELLO switch(a)
C. Compiler error {
D. None of the above. case 0: printf("0 ");
case 3: printf("3 ");
51. What is the output of C Program.? case 5: printf("5 ");
default: printf("END");
int main(){ break;
int k, j; }
for(k=1, j=10; k <= 5; k++) return 0;
{ }
printf("%d ", (k+j));
}
A. 5 END
return 0;
B. 0 3 5 END 0 3 5 END
}
C. 0 3 5 ENDEND
A. compiler error D. 3 5 ENDEND
B. 10 10 10 10 10
C. 10 11 12 13 14 15 54. What is the output of C program with
D. None of the above switch statement or block?
int main(){
52. What is the output of C Program? char code='K';
switch(code)
int main(){
{
int k;
case 'A': printf("ANT ");
for(k=1; k <= 5; k++);
break;
{
case 'K': printf("KING "); break;
printf("%d ", k);
default: printf("NOTHING");
}
}
return 0;
printf("PALACE");
}
}
A. 2345
A. KING
B. 1234
B. KING NOTHING
C. 6
C. ANT KING
D. 5
D. Compiler error

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)


Page 10 of 12

55. What is the output of C Program with 58. What should be the output:
Strings?
int main() {
#include “stdio.h” int a = 19%10%5;
int main() printf("%d",a);
{ }
char ary[] = "Discovery Channel" ;
printf("%s",ary); A. 2
return 0; B. 4
} C. 0
D. Compilation Error
A. D
B. Discovery Channel 59. What should be the output:
C. Discovery
D. Compiler error int main() {
int a = 5;
int b = 10;
56. Read the following C program :
int c = a+b;
int main() printf("%i",c);
{ }
const x = 10;
A. 0
{
B. 15
int x = 0;
C. Undefined i
printf("%d",x);
D. Any other Compiler Error
}
return 0;
60. What should be the output:
}
int main(){
What will be the output:
int x;
A. 10 x=10,20,30;
B. Compilation Error printf("%d",x);
C. 0 }
D. Undefined
A. 10
B. 20
57. What should be the output:
C. 30
#include <stdio.h> D. Compilation Error
Int main()
{ 61. What will be the output?
int a = 10/3;
int x;
printf("%d",a);
for(x=5; x<10;x+=5)
return 0;
} printf(“%d”,x);

A. 3.33
B. 3.0 A. 5 10
C. 3 B. 5
D. 0 C. 0
D. Compilation error

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)


Page 11 of 12

62. What will be the output of the following 64. What will be the output of the following
program? code?
# include <stdio.h>
char ch=‘c’;
Int main(void) switch(ch) {
{ case ‘a’:
int x,y,z1,z2,z3; printf(“\n Good Morning! ”);
x=17, y=5; break;
case ‘b’:
z1=x/y;
printf(”\n Have a Nice Day! ”);
printf(“\nz1=%d”,z1);
break;
z2=x%y; case ‘c’:
printf(“\nz2=%d”,z2); printf(“\n Good Bye! ”);
z3=y++; break; }
printf(“\nz4=%d”,z4);
} A. Good Morning!
B. Have a Nice Day!
A. z1=3.5, z2=2.0,z3= 6
C. Good Bye
B. z1=3.5, z2=2,z3= 6
D. None
C. z1=3, z2=2,z3= 6
D. z1=3, z2=2,z3= 5
65. What will be the output of the following
codes?
63. What will be printed when the following int main(){
code is executed? int x;
int n=28; for(x=0; x<10;x++)
count=15; printf(“%d”,x);
sum=30; }
if (n<25)
A. 0 – 10
{
B. 1 – 10
count=count+5;
C. 0–9
sum=sum+n;
printf(“\nCount=%d”,count); D. 1–9
printf(“\tSum=%d”,sum);
} 66. What will be the output of the following
else program?
{ int main() {
count=count-5; int k;
sum=sum+n;
while(k<=10){
printf(“\nCount=%d”,count);
printf(“\n%d”, k);
printf(“\t Sum=%d”,sum);
} k++;
}
A. Count=15 Sum=58 }
B. Count=10 Sum=58
C. Count=15 Sum=58 A. 0 – 10
D. Compilation error B. 1 – 10
C. 0–9
D. 1–9
Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)
Page 12 of 12

67. What will be the output of the following E.


codes? 70. What will be the output of the following
codes?
int main()
{ int main(){
int n;
char a;
while (a=0; a<255 ;a++) for(n=15; n >= 10; n = n-5)
printf(“%c”,a); printf(“\n%d”,n);
} }
A. 0 – 10 A. 15 20
B. 1 – 10 B. 15 10
C. 0–9 C. 15 5
D. Compilation error D. 5 15

68. What will be the output of the following 71. What will be the output of the following
codes? codes?
int main() int main(){
{ int k, a;
k = 1;
int x = 1;
a = 3;
while (x ==1){
printf(“\n%f \t %f”,k , k*a, );
x=x+1;
k = k + 1;
printf(“%d”, x);
}
}
} A. 1 3
B. 1.000 3.000
A. 0
C. 0.0000 0.000
B. 1
D. Compilation error
C. 2
D. 3

69. What will be the output of the following


codes?
int main()
{
int x =4 , y = 6;
x = --x;
y = x--
printf(“x=%d, y=%d”,x, y);
}
A. x=3 y=4
B. x=1 y=3
C. x=2 y=4
D. x=2 y=3

Alternate to Practical(Computer-X) -Ghulaman-e-Abbas Scool- (By :Sir Gul Faraz Azeemi)

You might also like