#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h> // fabs()
int main()
{
/*
Relational Operators
< is less than
<= is less than or equal to
== is equal to
>= is greater than or equal to
> is greater than
!= is not equal to
*/
int n = 0;
while (n++ < 5) // n++ < 5 is a relational expression
printf("%d ", n);
printf("\n");
char c = 'A';
while (c != 'Z')
printf("%c ", c++);
1 2 3 4 5
출력
A B C D ... X Y
출력
const double PI = 3.14159265358979;
double guess = 0.0;
printf("Input pi : ");
scanf("%lf", &guess);;
while (guess < PI)
{
printf("Fool! Try again.\n");
scanf("%lf", &guess);
}
printf("Good!");
while (fabs(guess - PI) > 0.01)
fabs()
는 절댓값을 출력해내는 함수이다.
#include <math.h>
를 입력해야지 사용할 수 있다.