MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
SYMBACA 2K24
DEPARTMENT OF MASTER OF COMPUTER APPLICATIONS
DEBUGGING (ROUND 1)
C PROGRAMMING
1. Point out the error in the program.
#include<stdio.h>
int main()
{
char ch:
int i;
scanf("%c", &i);
scanf("%d", &ch);
printf("%c %d", i);
return 0;
}
2. Point out the error in the program.
#include<stdio.h>
int main()
void patternPrint(int n)
{
int print=1,i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",print);
printf("\n");
}
}
}
3. Point out the error in the program.
#include < stdio.h >
int main()
{
printf("This is an"error free" program");
return 0;
}
4. Point out the error in the program.
#include < stdio.h >
int main(){
int n1,n2,n3;
scanf("%d %d %d",&n1,&n2,&n3);
if(n1>n2) && (n1>n3)
printf("%d",n1);
elseif ( n2>n3)
printf("%d",n2);
else
printf("%d",n3);
return 0;
}
5. Point out the error in the program.
#include <stdio.h>
int main()
{
Char buf[12];
stderr = stdout;
fscanf(stderr, "%s", buf);
printf("%s\n", buf);
}
6. Point out the error in the program.
#include < stdio.h >
int main()
{
int z = 8 = 9 = 7 ;
printf("%d",z);
return 0;
}
7. Point out the error in the program.
#include <stdio.h>
int main()
{
int r, s, c;
c = scanf("%f%d", &r, &s);
if (r + s + c) {
printf("This is a game");
}
else {
printf("you have to play it");
}
return 0;
}
8. Point out the error in the program.
#include <stdio.h>
#include <string.h>
int main()
{
char a[] = "%s\n";
a[5] = 'i';
printf(a, 85);
}
9. Point out the error in the program.
void test(struct number n)
{
n*x=100;
}
struct number{ int x; }
int main()
{
struct number num;
test(num);
printf("%d\n",num.x);
return 0;
}
10. Point out the error in the program.
#include <stdio.h>
int main()
{
int a[2][2] = { 1, 2, 3, 4 };
int *p;
p= &a[1][1];
printf("%f\n",p);
return 0;
}
11. Point out the error in the program.
#include <stdio.h>
int main()
{
int num, LD;
printf(" Enter a number"4589);
scanf("%d", &num);
LD = num / 10;
printf(" \n The Last Digit of a Given Number %d = d", num, LD);
return 0;
}
12. What will the output of the following program?
#include <stdio.h>
int main()
{
int a = 3, b = 5;
int t = a;
a = b;
b = t;
printf("%d %d", a, b);
return 0;
}
13. What will be the output of the following program?
#include <stdio.h>
void solve() {
int a[] = {1, 2, 3, 4, 5};
int sum = 0;
for(int i = 0; i < 5; i++) {
if(i % 2 == 0) {
sum += *(a + i);
}
else {
sum -= *(a + i);
}
}
printf("%d", sum);
}
int main() {
solve();
return 0;
}
14. Point out the error in the program.
#include<stdio.h>
int main()
{
int a=10;
Void f();
a = f();
printf("%d\n", a)
}
void f()
{
printf("Hi");
return 0;
}
15. What will the output of the following program?
#include<stdio.h>
int* f()
{
int x = 5;
return &x;
}
main()
{
printf("%d"\, f());
}