WorksheetsTECHFEST 2K21 (DEBUGGING)
Total questions: 10
Worksheet time: 8mins
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);
}
}
No error
App myApp = new App(10);
Index=index[0]
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");
}
}
n=n%10;
A=n%10; ,if(temp==c)
if(temp==null)
<?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>
for($i=0;$i<=$num-1;$i++)
for($i=8;$i<=$num-1;$i++)
for($i=2;$i<=$num-1;$i++)
<?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]." ";
?>
n=count($numbers); , for ( $c = 0 ; $c < $n ; $c++ )
no error
n=count($numbers=100);
def hanoi(x):
if x == 1:
return 1
else:
x = int(input("ENTER THE NUMBER OF DISKS: "))
print('NUMBER OF STEPS: ', hanoi(x))
return 1*hanoi(x-1) + 1
return 2*hanoi(x-1) + 1
return 2*hanoi(x+1) + 1
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
start_time = time.time() , end_time = time.time()
no error
end&start_time = time.time()
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");
}
left= number%10;
rev = rev * 10 + left;
number=number/10;
rev=rev*10+right
no error
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;
}
sum==arr[i];
sum==0
sum += arr[i];
#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;
}
num = num % 20 ; , base = base * 2;
num = num / 10 ; , base = base * 2;
num = num / 10 ; ,base = base %2;
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;
}
no error
return Search(a,mid+1,last,item); , return Search(a,start,mid-1,item);
return Search(a,mid-1,last+item);
