Download as pdf
Download as pdf
You are on page 1of 3
of Engineering - Mechatronics Computer Programming Language (1) - slude main() { ant sum =244/2+6%2; Printf("xd", sum); return @; > ©» ilude main() { const int i = 55 printf("Xd, Xd\n", itt, ++i); return 5 Os Os 67 5,7 slude slude main() { Ant i = 0; For(s4 main() { ant x= 55 “f (x == 5) ( Af (x == 5) break; printf ("Hello wrintf ("HE") 5, A 18. include int main() { int i= while(i- printf("md "s 4s return 05 , @as210 @s21 19. include int main() { char *str = "Hello, there”; print#("%s", str+2); return 0} 20. include int main() { int a= 2, b= Sf (4a > 5 8& --b <5) % printf("%d, Xd", a, b); >.» GSD) ©» 21. include int main() { int i, 35 for (i= @ 3 <4} ise) printf("%a%e", i, 3); return @; } @oaaes GB) on 12 23 38 22. include void fn(int *p) { int j= 25 p= 8j; printf("xd ", wma *P)s y int main() { int 1 = 97, tp = &i; n(p)s print#("%d ", *P); } @2 @ze Or" ©: ester - 2022/2023 Version (D) -page 2/3 Dr. Sami AL-MAQTARI Faculty of Engineering - Mechatronics 23. #include int main() { int x = (10/3)*3+5%3; int y = (2392) % (int) 5.53 printf("xd, Xd", x, y)5 return 0; Our Ors @unr 24. ttinclude int main() { int first = 10, second = 20; int third = first + second; { int third = second - first; print€("xd, ", third); Printf("%d", third); return 93 } @ 20, 10 @ 10, 20 (©) 30, 2S. #include void Pecurse(int x) { Sfx == 0) ( Print ("xd ", x)5 return; ? Printf("xa ", x); Pecurse(x - 1); Printe("xd ", x3 int main() ¢ recurse(3 return 0; } pre ®3210..0 (6 #include int main() ¢ int ch = 25 switch (ch) ¢ case 1: printé("1 “); case 2: printé("2 "); case 3: print#(*3 default: printer"); , > Feturn 95 > 2s ae>°*-: “Semester - 2022/2023 Version (D) -page 3/3 Computer Programming Lang, 27. include int main() { int a b += ate by printf("%d, Xd", a, b)5 b= 25 @5> Gyo» © 28.Hinclude int main() ( int 4, 45 printf(°%d ", 43 return 5 29. #include int main() ( int i= 3 while (ite print#(” 246\O2) Oss 30. include int main() ( int af] = (2, 2, 3, a}; int 4, sum = 0; for (i= 0; i < a ist) sun += ali]s print#("%d: %3", 4, sum); return 0; @ue G=Do« @ss> @ x2 Dr. Sami AL-MAQTAF Faculty of Engin Name: ing Mechatronics Engineering © Id: 5 Computer Programming Language (1) - C Answer the following questior 1. How many times the word "Hello" is printed? Winclude int main() ( printf("Hello\n"); main(); return 0; @ 2. Mow to find the length of te arr ol dedarstion? ® stze0f(0) ® sizeot(ay/stzeor(ale) Ce) sizeot+a) Ose 3. what will the variable “val” be equal to after the following operation: GES «. o. 4. In order to get an integer number entered from the Keyboard into variable "x" we use the statement: @) scang("xe",x)5 6d" 8X) 3 > sant", 05 5.What will be the value of "rés" after the following code snippet? int a= 3; int res @n 6. Ifp isan integer pointer with a value 1009, then what will the value a + Sbe? © mnee Xo) forever y "a" in Cin its place will be the value of x" in the following, int x = nd an assignment Gs) 9. Give the following declarations statement: char str[80]; char * p = str Which one is equivalent to the x str[4]? Su @®) ecoray @ 10. How many times the loop in the following diagram will repeat? include int main() ¢ char 5 = for (5 J < 300; J++) printé('xc: fd\n", 5, 305 return 0; a @ @® 300 ©28 ©) 299 Find dhe output foreach ofthe following programs: 11. Finclude int main() { int a= 3, b= 3,6 = Hat bets print(°%4", €)5 return @; 12. include int get(int n) 4f(n <= 1) return nj return get(n - 1) + get(n - 25 @> i int main() { printf("Xd", get(6)); return 0; ® (©) © nd Semester - 2022/2023 Version (D) -page 1/3 Dr. Sami AL-fy

You might also like