일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- System
- API
- WebProgramming
- OOP
- windows
- request
- 노드
- Sort
- C
- 악성코드
- meta
- java
- UTF-8
- 윈도우즈
- 포인터
- jsp
- Kafka
- c++
- function
- CSS
- beans
- query
- array
- HTML
- CLASS
- Call-by-reference
- 자료구조
- 투자
- algorithm
- JavaScript
- Today
- Total
hahahia
컴입 과제 - 반목문(for, while, do while)을 이용한 factorial 출력program 본문
/* made by hahahia */
#include <stdio.h>
int main()
{
int n, i, fact=1;
printf("input n(1~15) : ");
scanf("%d", &n);
for(i=1; i<=n; i++)
{
fact *=i;
}
printf("%d! = %d\n", n, fact);
return 0;
} // for 문을 이용한 factorial program
#include <stdio.h>
int main()
{
int n, i=0, fact=1;
printf("input n(1~15) : ");
scanf("%d", &n);
while(i<n)
{
i++;
fact *=i;
}
printf("%d! = %d\n", n , fact);
return 0;
} // while 문을 이용한 factorial program
#include <stdio.h>
int main()
{
int n, i=0, fact=1;
printf("input n(1~15) : ");
scanf("%d", &n);
do{
i++;
fact*=i;
}while(i<n);
printf("%d! = %d\n", n, fact);
return 0;
} // do while 문을 이용한 factorial program
'Language > C' 카테고리의 다른 글
지역 변수와 전역 변수 (0) | 2011.05.22 |
---|---|
C언어 함수 (0) | 2011.05.22 |
ab + ba = 99 를 만족하는 a, b값 구하는 프로그램 (0) | 2011.05.13 |
break와 continue의 차이 (0) | 2011.05.13 |
반복문 3가지의 특징(for, while, do while) (0) | 2011.05.10 |