{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 20091_final - Dept of Computer Eng Student Name Surname...

This preview shows pages 1–3. Sign up to view the full content.

Dept. of Computer Eng. Fall 2009 CEng 230 Final Examination Jan. 12, 2010 75 Minutes EXAM GROUP A Student Name & Surname Student ID Use the below program to answer next 2 questions. int days_in_feb(int y) { if(y % 100 == 0) return 28; if(y % 4 == 0) return 29; return 28; } int dyear ( int day , int month, int year ){ int day_of_year ; day_of_year = day ; for( ; month > 0; month--) switch ( month ) { case 11: case 9 : case 6: case 4 : day_of_year += 30; break; case 10: case 8 : case 7: case 5 : case 3: case 1 : day_of_year += 31; break; case 2: day_of_year += days_in_feb( year ); } return day_of_year ; } 1. What is the value returned by dyear(1,3,2009)? a) 1 b) 32 c) 60 d) 91 e) 30 2. There is an error in this program. Which of the below corrections would fix this error? a) switch (month) switch(month -1) b) for(; (month-1)>0 ; month--) for(; (month-1) > 0 ;) c) return 28 return ( (month == 2)? 28:29) d) switch (month) switch(month +1) e) There is no error. 3. What is the value of “y” after below code segment is executed? int x1 = 7, x2 = 10, x3 = 8.1, y ; y = x3>x1 – x2<=10 ; 4. What is the output of the below code? #include <stdio.h> int fun (int ix){ ix = ix * 2 ; printf ("%d " , ix); return ix ; } int main (void) { int x = 3 ; printf ("%d ", x); printf ("%d\n", fun(x)); return 0 ; } 5. What is the output of the below program with input “3” #include<stdio.h> int fonksiyon ( int gln ) { if( gln <= 1 ) return 1; else return (gln*fonksiyon(gln– 1)); } int main ( void ) { int k,N,f; puts(“Enter an integer: “); scanf ( “ %d “ , &N ); f= fonksiyon(N); printf(“Result is=%d\n“, f ); return 0 ; } 6. What is the mistake in the below switch statement? double a= 1.25; switch(a){ case 1.1: case 1.2: x= x*x; y= x; break; case 1.3: y= x*x; case 2.1: case 3.3: y= sqrt(x); break; case 3.5: printf(“Error “); break; default: y= x+1; a) “case 1.3” has no break b) “default” doesn’t have “printf” c) “a = 1.25” is not matched. d) “switch” works only with integers e) “case 3.5” doesn’t need “break”

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
7. How can you code the below condition in C? “x and y are both greater than z” a) a) x > z && y > z b) b) x && y > z c) c) (x && y) > z d) d) (x | | z ) > z e) e) x > z | | y > z 8. If a=1 and b=20 what is the output of the below code segment? if(a=10){ if(b == 20) printf(“*** ”); } else printf(“*****”) ; 9. What is the effect of the following code segment? int i; for (i=1;i <21;i++) if (i%3 == 0) printf(“%4d”,i);
This is the end of the preview. Sign up to access the rest of the document.
• Spring '09
• Assoc.Prof.Dr.CEMHÜSEYİNBOZŞAHİN
• Following, Christopher Nolan, ASCII, Void type, Division by zero, Defined and undefined

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern