CC1_L12_LAB TASK 1
CC1_L12_LAB TASK 1
Laboratory Task
Course Code / Course Name : 10211CS306 / Competitive Coding – 1
Year / Semester : 2023-24 / SUMMER
Faculty Name : Ms.R.Priyadharshini
Class Slot : L12
Task 1: Point out the Syntax and Semantic errors in the code snippet, and debug -CO1
K3
1) #include <stdio.h>
int main()
{
a = 10;
printf("The value of a is : %d", a);
return 0;
}
2) #include <stdio.h>
int main()
{
int a=2;
if(.)
printf("a is greater than 1");
return 0;
}
3) #include <stdio.h>
int main()
{
int a,b,c;
a=2;
b=3;
c=1;
a+b=c;
return 0;
}
4) #include <stdio.h>
void main()
{
int a, b, c;
a + b = c;
}
5) #include <stdio.h>
void main()
{
int x = 10;
int y = 15;
printf("%d", (x, y))
}
(a) x = ( y + 3 ) ;
(b) cir = 2 * 3.141593 * r ;
(c) char = ‘3’ ;
(d) 4 / 3 * 3.14 * r * r * r = vol_of_sphere ;
(e) volume = a3 ;
(f) area = 1 / 2 * base * height ;
(g) si = p * r * n / 100 ;
(h) area of circle = 3.14 * r * r ;
(i) peri_of_tri = a + b + c ;
(j) slope = ( y2 – y1 ) ÷ ( x2 – x1 ) ;
(k) 3 = b = 4 = a ;
(l) count = count + 1 ;
(m) charch = '25 Apr 12' ;
# include <stdio.h>
intaddmult ( int, int )
int main( )
{
inti = 3, j = 4, k, l ;
k = addmult( i, j ) ;
l = addmult( i, j ) ;
printf ( "%d %d\n", k, l ) ;
return 0 ;
}
int addmult ( int ii, intjj )
{
intkk, ll ;
kk = ii + jj ;
ll = ii * jj ;
return ( kk, ll ) ;
}
b)
# include <stdio.h>
void message( ) ;
int main( )
{
message( ) ;
message( ) ;
return 0 ;
}
void message( ) ;
{
printf ( "Praise worthy and C worthy are synonyms\n" ) ;
}
Bug1
int choice;
scanf(“%d”,choice);
Bug2
inti=10;
while(i=10)
{
printf(“got to get out”);
i++;
}
Bug 3
int j=1;
While(j<=100);
{
printf(“\nCompguard”);
j++;
}
while(j<=100);
Bug 4
intch=1;
switch(ch)
{case 1:
printf(“\nGoodbye”);
case 2:
printf(“\nLieutenant”);
}
Bug 5
yr=romanise(year,1000,`m’);
Bug 6
area= area_circle(1.5);
Bug 7
#define UPPER 25;
if(counter==UPPER)
if(counter==25;)
Bug 8
#define SQR(x)x*x
a=25/5*5;
Bug 9
#define ABS (a)(a=0?a:a)
Bug 10
charch ;
for ( ch = 0 ; ch<= 255 ; ch++ )
printf ( "\n%c %d", ch, ch ) ;