Code Debugging RAW
Code Debugging RAW
Challenge Description
In this round, you need to identify and fix syntax errors in code snippets
across three programming languages.
C Language
#include <stdio.h>
int main() {
int a = 5, b = 10;
printf("Sum of two numbers: " + a + b);
return 0;
}
C++ Language
#include <iostream>
using namespace std;
int main() {
int x = 8, y = 12;
cout << "The sum is: " << x + y << endl
return 0;
}
Python Language
def calculate_average(numbers):
total = sum(numbers)
average = total/len(numbers)
return average
my_list = [4, 7, 9, 2, 8]
result = calculate_average
print(f"The average is: {result}")
Challenge Description
In this round, you need to identify and fix logical errors in loop constructs
across three programming languages.
C Language
#include <stdio.h>
int main() {
int i = 1;
while (i < 5);
{
printf("%d ", i);
i++;
}
return 0;
}
C++ Language
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> values = {10, 20, 30, 40, 50};
int sum = 0;
cout << "Sum of odd-indexed elements: " << sum << endl;
return 0;
}
Python Language
i = 1
while i <= 5:
print(i)
i = i - 1
Challenge Description
In this round, you need to identify and fix memory/runtime errors in code
snippets across three programming languages.
C Language
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node* next;
};
int main() {
struct Node* head = (struct Node*)malloc(sizeof(struct Node));
struct Node* second = (struct Node*)malloc(sizeof(struct Node));
struct Node* third = (struct Node*)malloc(sizeof(struct Node));
head->data = 1;
head->next = second;
second->data = 2;
second->next = third;
third->data = 3;
third->next = NULL;
printList(head);
free(head);
free(third);
return 0;
}
C++ Language
#include <iostream>
using namespace std;
int main() {
int n = 5;
int *arr = new int[n]{4, 2, 7, 1, 8};
int max_val = arr[0];
for (int i = 0; i <= n; i++) {
if (arr[i] > max_val)
max_val = arr[i];
}
delete arr;
cout << "Maximum: " << max_val << endl;
return 0;
}
Python Language
arr = [4, 8, 1, 6]
max_val = arr[0]
for i in range(5):
if arr[i] > max_val:
max_val = arr[i]
print("Max:", max_val)