Presentation is loading. Please wait.

Presentation is loading. Please wait.

Homework 2 (due:May 13th) Deadline : May 11th 11:59pm

Similar presentations


Presentation on theme: "Homework 2 (due:May 13th) Deadline : May 11th 11:59pm"— Presentation transcript:

1 Homework 2 (due:May 13th) Deadline : May 11th 11:59pm
Where to submit? eClass 과제방 ( How to submit? Create a folder. The name of the folder should be “studentID#.hw2”. (ex) hw2 We have three problems in hw2. Make four C source files. The name of the source files should be the format “studentID#.hw2.#.c” (ex) hw2.1.c , hw2.2.c , …, hw2.4.c In each source file .c, your code must have comments that include your name and student_id# Put the source files into the folder we created. Compress the folder into a zip file. The name of the zip file should be “student#.hw2.zip”. (ex) hw2.zip Upload the zip file into eClass website. If you don’t follow above instructions, you may get penalty in your score. You must do programming yourself.

2 Input example output example  64+16+8+2+1
1.Input an integer B containing only 0 and 1 (i.e.,a binary integer) and print its decimal equivalent. Assume the total number of the binary digits is less than 10. #include <stdio.h> int main() { int B; // you may declare variables here scanf(“%d”,&B); // put your code here return 0; } Input example output example 91

3 Input example  64+16+8+2+1 output example
2.Input a (decimal) integer value N and print its equivalent binary value containing 8 digits of only 0 and 1. Assume 0<=N<=255. #include <stdio.h> int main() { int N; // you may declare variables here scanf(“%d”,&N); // put your code here return 0; } Input example 91 output example

4 Input example output example
3. One interesting application of computers is histogram. Write a program that reads three numbers (each between 1 and 30). For each number read H, your program should print a line containing that number H and H adjacent asterisks. For example, if your program reads the number seven, it should print 7:*******. Be careful about the alignment. #include <stdio.h> int main() { int h1,h2,h3; // you may declare variables here scanf(“%d %d %d”,&h1,&h2,&h3); // put your code here return 0; } Input example 3 15 8 output example 3:*** 15:*************** 8:********

5 Input example output example Input example output example
4. Korean Gymnastic Association is trying to modify the scoring system in order to improve its fairness. In the previous system, each of 5 judges gives a score from 1 to 10. The sum of the scores except the maximum and the minimum score becomes the final total score. To improve the previous system, we first remove the maximum and minimum scores out of the 5 scores. Then, if the difference between the maximum and the minimum scores out of the remaining 3 scores is 4 or more, the scores need to be re-evaluated. Write a program that takes 5 scores as an input and print the total score. If the score needs to be re-evaluated, print KIN (Keep In Negotiation). Input example output example 24 Input example output example KIN


Download ppt "Homework 2 (due:May 13th) Deadline : May 11th 11:59pm"

Similar presentations


Ads by Google