NEW
Font size
WorksheetsSkill Development - Debugging Practice1
Total questions: 10
Worksheet time: 10mins
What will be the final value of x in the following C code?
#include <stdio.h>
void main()
{
int x = 5 * 9 / 3 + 9;
}
3.75
Depends on Compiler
24
3
How many times i value is checked in the following C program?
#include <stdio.h>
int main()
{
int i = 0;
while (i < 3)
i++;
printf("In while loop\n");
}
2
3
4
1
What is the output of this C code?
#include <stdio.h>
main()
{
int n = 0, m = 0;
if (n > 0)
if (m > 0)
printf("True");
else
printf("False");
}
True
False
No Output will be Printed
Run Time Error
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 1, b = 1, c;
c = a++ + b;
printf("%d, %d", a, b);
}
a = 1, b = 1
a = 2, b = 1
a = 1, b = 2
a = 2, b = 2
What will be the output of the following C# code?
int i, j = 1, k;
for (i = 0; i < 3; i++)
{
k = j++ - ++j;
Console.Write(k + " ");
}
-4 -2 -2
-6 -4 -1
-2 -2 -2
-4 -4 -4
Find out the error, if any in the below program?
#include<stdio.h>
int main()
{
int i = 1;
switch(i)
{
case 1:
printf("Case1");
break;
case 1*2+2:
printf("Case2");
break;
}
return 0;
}
Error: in switch statement
Error: in case 1*2+4 statement
Error: No default specified
No Error
What will be the output of the following C# code?
struct abc
{
int i;
}
class Program
{
static void Main(string[] args)
{
abc x = new abc();
abc z;
x.i = 10;
z = x;
z.i = 15;
console.Writeline(x.i + " " + y.i)
}
}
10 10
10 15
15 10
15 15
1. What will be the output of the following code snippet?
using System;
class program
{
static void Main(string[] args)
{
int x = 8;
int b = 16;
int c = 64;
x /= c /= b;
Console.WriteLine(x + " " + b+ " " +c);
Console.ReadLine();
}
}
2 16 4
4 8 16
2 4 8
8 16 64
What will be the output of the following C# code?
static void Main(string[] args)
{
int i, j;
int[, ] arr = new int[ 3, 3];
for (i = 0; i < 3; ++i)
{
for (j = 0; j < 3; ++j)
{
arr[i, j] = i * 2 + i * 2;
Console.WriteLine(arr[i, j]);
}
Console.ReadLine();
}
}
0, 0, 0 4, 4, 4 8, 8, 8
4, 4, 4 8, 8, 8 12, 12, 12
. 8, 8, 8 12, 12, 12 16, 16, 16
0, 0, 0 1, 1, 1 2, 2, 2
Which is the correct way of defining and initializing an array of 3 integers?
int[] a={78, 54};
int[] a;
a = new int[3];
a[1] = 78;
a[2] = 9;
a[3] = 54
int[ ]a;
a = new int{78, 9, 54};
int[ ] a;
a = new int[3]{78, 9, 54};
