0 ratings 0% found this document useful (0 votes) 17 views 4 pages C Assignment 1
The document contains numerous code snippets with various syntax errors and logical issues in C programming. It highlights problems in variable declarations, incorrect function usage, and formatting errors in print statements. Overall, it serves as a compilation of common coding mistakes for educational purposes.
AI-enhanced title and description
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
Save c assignment 1 For Later 32. Find error(s) in the following scant
scanf ("*d%£", Smarks, gay a
, 'S) i
Give the output of the following progr:
4, #include ae
main()
{
int x=3, y=5, z=7;
int a, b;
aaxt2+y/5-2+y;
b= 44x * (y - 3) / 2 - zt ty;
printf ("\n a = %d", a);
printf ("\n b = %d", b);
return 0;
}
2. #include
main()
{
int a,b =3;
char c ='‘A']
azb+tcG
printé ("\n a= 3d", a7
return 0;
}
3, #include
main()
{
int a7
4/3 + 1/3)
printf ("\n sd", 4.0/3.0)
printf ("\n gen, 1.0/3.0 *
a = 15/10.0 + 3/27
printé("\n *4", ali
return 0;
}
4, #include
int main()
{
int a = 4)7
© scanned with OKEN Scanner56 | Introduction to ¢ Programming -
| 56 | invoductons I
printf(*\n td", 10 ¢ ase);
printf(*\n td", 10 6 sea;
}
5. include
main0)
{
intas 4, be 5, 6
asd
printf("\n a= td, a;
return 0;
& #include
#include
main)
(
int ai, be2, c3, dea,
elrser();
ress asb/e-dte
printf (*\n Result = $4" res);
res= (a+b) /o-d*e;
printé(*\n Result = td",res);
ress a+ (b/ (c -d)) te;
printf (*\n Result = $4",res);
retum 0;
}
7. Sinclude
main()
{
intas4,b=5;
printf("\n 44",
return 0;
(a > b)? a: bi;
& Sinclude
int main()
{
Ane
Prion na see
rene bate | bea
prlnte(nn wales Seg,
ea+ (0/2.06e0.0cu3/s,
Print£(*"\n ta =, res); zea
Ollaro,
a
return 0;
winclude
Ant main ()
{
int a = 20,b = 5, result,
float c = 20.0, d= 5.0;
printe(*\n20+a/4*B=44", 1044/44,
printe("\ne/d*b+a-b=¥d",c/d+bya.4
return 0;
}
10.#include
int main()
(
int a, by
printf("\n a= $d \tb= td \tasy
= a", a, by atbl;
return 0;
}
1. #include
int main()
{
printé("\n a",
return 0;
“Fy;
}
12.#include
int main()
{
int n= 2;
printf ("\n n = 4a"
return 0;
}
13.#include
int main()
{
int a= 100, b = 3;
float ¢;
c= afb;
printf ("\n c = sé",
return 0;
eo:
}
[Link]
int main()
A
© scanned with OKEN Scannerou,
“aby,
printt("\n a «
b= vey,
Printe(n\n a yyy Vit ath;
aa Deinee(vn a (9s my
PEANEEC\N a ta bw ge SME?
return 0; tn,
)
cei 21. #include <[Link]
its int maint)
c, a {
pede
eae? int a= 2;
a ) ana e sass
TOL gga tt or printf (*\n ”
int result;
seein = Se result =345-1#17%-13;
oe printé "4d", result);
result =3*2+ (15/487;
printf ("ta®, result};
se result =28/9/342"2*5820/4
ain) printé ("
)
23,#include
got main)
(
na sd 88h BH
printé("\n
}
eta: aa pinclude
main()
tae 2, b= 3; }
Frintt(*\n 844, 40a BI
return 0;
0.0
25,pinclude numbers ") ; Pigg
int main() scanf ("8£", &b);
{ print€("\n The numbers are , 4
printf ("\n %40.27s Welcome to ¢ BE", a, b); “
programming") ; return 0;
print£("\n 40.208 Welcome to ¢ }
programming") ;
Print£("\n %40.14s Welcome to ¢ ; Penichude sstdio:he.
programming") ; seein)
{
char a, b, ci
print£("\n Enter three characters
printf ("\n $-40.27s Welcome to C
Programming") ; scanf ("$c %c $c", &a, &b, &);
Print£("\n #-40.20s Welcome to ¢ MP
Programming") ;
printf("\n a = %c b = $c and
printf ("\n $-40.14s Welcome to ¢
a, b, ©);
programming") ; xeturn 0;
i
return 0;
} 30. #include
{
27.#include
main()
{
int x=10, y=20, res;
Fes = yi + x44;
Fes $2 Hy + 44x;
printf ("\n x= %d y= 4d RESUIT=
fa", x,y, res");
return 0;
int a= -21,b = 3;
printf ("\n %d", a/b + 10);
b= -b;
printf("\n %d", a/b + 10); }
return 0;
}
31. #include
{
28.t#include
int x=10, ye20, res,
main() res = x++4b;
fi print£("\n x = $y = 44 RESULTS
men 4a", x,y, resn);
float retum 0;
t
i
© scanned with OKEN Scanner