Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

TECHFEST 2K21 (DEBUGGING)

Total questions: 10

Worksheet time: 8mins

Name
Class
Date
1.

class Super {

public int index = 1;

}

class App extends Super {

public App(int index) {

index = index;

}

public static void main(String args[]) {

System.out.println(myApp.index);

}

}

a)

No error

b)

App myApp = new App(10);

c)

Index=index[0]

2.

class Armstrong{

public static void main(String[] args) {

int c=0,a,temp;

int n=153;

temp=n;

while(n>0)

{

a=n/10;

n=n/10;

c=c+(a*a*a);

}

if(temp==a)

System.out.println("armstrong number");

else

System.out.println("Not armstrong number");

}

}

a)

n=n%10;

b)

A=n%10; ,if(temp==c)

c)

if(temp==null)

3.

<?php


if(isset($_POST['sub']))


{ $fibo=array(0,1);


$num=$_POST['nm1'];


{


$fibo[$i]=$fibo[$i-1]+$fibo[$i-2];


}


}


?>


<html>


<head>


<title>Fibonacci Series</title>


</head>


<body>


<table>


<form name="frm" method="post" action="">


<tr><td>Number of Terms:</td><td><input type="text" name="nm1" /></td></tr>


<tr><td></td><td><input type="submit" name="sub" /></td>


<td><center><span>


<?php if(isset($_POST['sub'])){


for($i=0;$i<=$num-1;$i++){echo $fibo[$i].",";}


}


?>


</span></center>


</td></tr>


</form>


</table>


</body>


</html>

a)

for($i=0;$i<=$num-1;$i++)

b)

for($i=8;$i<=$num-1;$i++)

c)

for($i=2;$i<=$num-1;$i++)

4.

<?php


$numbers=array(12,23,45,20,5,6,34,17,9,56);

for ($c = 0 ; $c < ( $n - 1 ); $c++)

{

for ($d = 0 ; $d < ($n - $c - 1); $d++)

{

if ($numbers[$d] > $numbers[$d+1]) /* For decreasing order use < */

{

$swap = $numbers[$d];

$numbers[$d] = $numbers[$d+1];

$numbers[$d+1] = $swap;

}

}

}


echo "Sorted list in ascending order <br />";

echo $numbers[$c]." ";


?>

a)

n=count($numbers); , for ( $c = 0 ; $c < $n ; $c++ )

b)

no error

c)

n=count($numbers=100);

5.

def hanoi(x):

if x == 1:

return 1

else:

x = int(input("ENTER THE NUMBER OF DISKS: "))

print('NUMBER OF STEPS: ', hanoi(x))

a)

return 1*hanoi(x-1) + 1

b)

return 2*hanoi(x-1) + 1

c)

return 2*hanoi(x+1) + 1

6.

import time

print("Press ENTER to start the stopwatch")

print("and, press CTRL + C to stop the stopwatch")

while True:

try:

input()

print("Stopwatch started...")

except KeyboardInterrupt: print("Stopwatch stopped...")

end_time = time.time()

print("The total time:", round(end_time - start_time, 2),"seconds")

break

a)

start_time = time.time() , end_time = time.time()

b)

no error

c)

end&start_time = time.time()

7.

void palindrome(int number)

{

int rev = 0,store, n1,left;

n1=number;

store= number;

while (number > 0)

{

left= number/10;

rev = rev + 10 * left;

number=number%10;

}

if(n1==rev)

printf("Number %d is Palindrome number",n1);

else

printf("it is not a Palindrome number");

}

a)

left= number%10;

rev = rev * 10 + left;

number=number/10;

b)

rev=rev*10+right

c)

no error

8.

int sumOfValue(int len, int* arr, int value)

{

int sum = 0;

for(int i =0 ; i < len; i++ )

{

if(arr[i]%value == 0)

sum =+ arr[i];

}

return sum;

}

a)

sum==arr[i];

b)

sum==0

c)

sum += arr[i];

9.

#include <stdio.h>

int main()

{

int num, binary_val, decimal_val = 0, base = 1, rem;

printf("Insert a binary num (1s and 0s) \n"); scanf("%d", &num);

binary_val = num;

while (num > 0)

{

rem = num % 10;

decimal_val = decimal_val + rem * base; num = num / 2 ;

base = base * 10;

}

printf("%d \n", binary_val);

printf("%d \n", decimal_val);

return 0;

}

a)

num = num % 20 ; , base = base * 2;

b)

num = num / 10 ; , base = base * 2;

c)

num = num / 10 ; ,base = base %2;

10.

int Search(int a[], int start, int last, int item) {

int mid;

if(last >= start)

{

mid = (start + last)/2;

if(a[mid] == item)

{

return mid+1;

}

else if(a[mid] < item){

return Search(a,start,mid+1,item);

}

else{

return Search(a,mid-1,list,item);

}

}

return -1;

}

a)

no error

b)

return Search(a,mid+1,last,item); , return Search(a,start,mid-1,item);

c)

return Search(a,mid-1,last+item);