# hw2

Document Sample

```					               Homework 2 (April 2th)
   Deadline : April 13th 11:59pm
   Where to submit? class board in miniWeb
   How to submit?
   Create a folder. The name of the folder should be “studentID#.hw2”. (ex)
20091499.hw2
   We have four problems in hw2. Make four C source files. The name of the
source files should be the format “studentID#.hw2.#.c”
   (ex) 20091499.hw2.1.c , 20091499.hw2.2.c ,
20091499.hw2.3.c , 20091499.hw2.4.c

   In each source file .c, your code must have comments that include your
name and student_id#
   Put the four 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) 20091499.hw2.zip
   Upload the zip file into miniWeb website.
   If you don’t follow above instructions, you may get penalty in your score.
   You must do programming yourself.
1. The factorial of an integer m is the product of consecutive integers from 1 to m. That is,
factorial m = m! = m x (m-1) x (m-2) x … x 1
write a program that computes and prints m! for any given m.
5  keyboard input
should be writen as
120  output
#include <stdio.h>

int main()
{
int val;

scanf(“%d”,&val);

}
2. Write a program that takes an integer decimal value from a keyboard (standard
input) and print a binary number of the value (as standard output). Your output
should have16 binary digits. (You may assume that input decimal value can be
represented with 16 bit integer number (less than 2^16.) For example,
21  keyboard input
should be writen as
0000 0000 0001 0101          output
#include <stdio.h>

int main()
{

}
3. Write a program that gets an arbitrary number of positive float values until -
1 is received from a keyboard (standard input) and print the mean and the
standard deviation of the positive float values. You may use following
formula :

#include <stdio.h>

int main()
{
float float_val;

while (1) {
scanf(“%f”,&float_val);

}

return 0;
}
4. Write a program that gets a starting principal(A, 원금), annual interest
rate(r, 연이율) from a keyboard (standard input) and print the total amount
on deposit (예치기간이 지난 뒤 총금액, 원리합계) for the year(n) from 0 to
10.

total deposit = A*(1+r)^n

For example,

1000.0 0.05   < - keyboard input   // 5% should be written as 0.05
0                 1000.00
1                 1050.00
2                 1102.50
3                 1157.62
4                 1215.51
5                 1276.28
6                 1340.10
7                 1407.10
8                 1477.46
9                 1551.33
10                 1628.89

```
DOCUMENT INFO
Shared By:
Categories:
Stats:
 views: 40 posted: 5/3/2011 language: English pages: 5
How are you planning on using Docstoc?