imported>장용운 |
imported>장용운 |
| (4 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| 장용운 C과제 HW1
| | 삭제해주세요 |
| | |
| | |
| == Write a program that reads a four digit integer and prints the sum of its digits as an output. ==
| |
| | |
| | |
|
| |
| //////////////////////////////
| |
| // C Programming Homework 1 //
| |
| //////////////////////////////
| |
| // //
| |
| // Problem Number : 1 //
| |
| // //
| |
| // Student ID : 20114924 //
| |
| // //
| |
| // Student Name : 장용운 //
| |
| // //
| |
| //////////////////////////////
| |
|
| |
| #include <stdio.h>
| |
| #define fdn four_digit_num
| |
|
| |
| int main(void) {
| |
| int fdn;
| |
|
| |
| scanf("%d", &fdn);
| |
|
| |
| // printf("The sum of four numbers : %d\n", (fdn/1000%10) + (fdn/100%10) + (fdn/10%10) + (fdn%10));
| |
| printf("The sum of four numbers : %d\n", (int)(fdn/1000) + (fdn/100%10) + (fdn/10%10) + (fdn%10));
| |
|
| |
| return 0;
| |
| }
| |
|
| |
|