{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# keyMidterm1 - CompE 102 Computer Programming Midterm 1...

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

CompE 102 Computer Programming Midterm 1 Spring 2007-8 1 KEY ATILIM UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING Inst.s: G.Kalem, Ö.Kılıç, D.Mishra, M.Rehan Duration: 90 min. Q1. Write a complete C program which reads 100 3-digit positive integer numbers one at a time and outputs how many of them satisfy the following condition. klm= k 3 + l 3 +m 3 , where k, l, m are integers. Ex: 153= 1 3 + 5 3 + 3 3 satisfies the condition Sample Run: Enter an integer: 101 Enter an integer: 153 …. …. 2 of the input numbers satisfy the condition #include <stdio.h> #include <math.h> int main() { int i, n, k, l, m, counter=0; for(i=0;i<100;i++) { printf(“Enter an integer:”); scanf(“%d”,&n); m=n%10; l=(n/10)%10; k=n/100; if(n==(pow(k,3)+pow(l,3)+pow(m,3))) counter++; } printf(“%d of the input satisfy the condition”,counter); return 0; } Name, Surname: Student no: Signature: Q1 (25 pts) Q2(25 pts) Q3 (25 pts) Q4(25 pts) TOTAL

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

View Full Document
CompE 102 Computer Programming Midterm 1 Spring 2007-8 2 Q2. a) (15 pts) Re-write the following code segment by using switch and for statements: b) (10 pts) Evaluate each of the following expressions if a = 5, b = 10, c = 15, and flag = 1.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 4

keyMidterm1 - CompE 102 Computer Programming Midterm 1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online