Computer Science ATP (X)
Computer Science ATP (X)
Computer Science ATP (X)
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
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
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
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
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
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
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
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
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
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
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