
int a, b, c;
a = b + c; /* 정수 + 연산 */
float d, e, f;
d = e + f; /* 실수 + 연산 */
이 모든것은 System을 제어하기 위한 목적이 크다. Operating system을 만들기 위한 랭귀지이다.
C에서 메모리 공간 확보를 하는 이유 : C는 고급언어를 가장한 저급 언어이다. Assembly를 살짝 포장해 놓은 제법 그럴듯한 모양을 가지고 있지만, 실제로는 저급언어이다.
#include <stdio.h>
int main(void)
{
int a, b, c; /* declaration */
float x, y = 3.3, z = -7.7; /* declaration with initializations */
printf("Input two integer: "); /* function call */
scanf("%d%d", &b, &c); /* function call */
a = b + c; /* assignment */
x = y + z; /* assignment */
...
}
a + b /* 변수의 연산 */
sqrt(7.333) /* 함수 호출 */
5.0 * x - tan(9.0/x) /* 함수호출과 변수연산 */
i = 7 /* 배정 수식 */
i = 7; /* 문장 */
3.777; /* 문법은 문제 없으나 용도가 없음 */
a+b; /* 문법은 문제 없으나 용도가 없음 */
x + 2 = 0 /* 틀림 */
x = x + 1; /* 배정 수식 */


문자는 ASCI코드로, 숫자로 표현된다.
#define BIG 200000000
int main(void)
{
int a, b = BIG, C = BIG;
a = b + c;
}
부동형 : float, double, long double
|Suffix|Type|Example|
|f or F|float|3.7F|
|l or L|long double|3.7L|
시험문제
#include <stdio.h>
int main(void)
{
int c;
while ((c = getchar()) != EOF)
if (c >= 'a' && c <= 'z')
putchar(c + 'A' - 'a'); /*숫자 뭐에서 뭘 빼면 어떻게 된다 시험문제에 나옴 */
else
putchar(c);
return 0;
}
이 코드는 입력받은 문자들 중 소문자만 대문자로 바꿔서 출력하는 프로그램이다.
#include <math.h>
#include <stdio.h>
int main(void)
{
double x;
printf("/n%s",
"The following will be computed:\n"
"\n"
" The square root of x\n"
" x raised to the power x\n"
"\n");
2) 이 경우, 이들 형들 중 모든 값을 int로 표현하라 수 있으면 int로 변환되고, 그렇지 않으면 unsigned int로 변환됨
3) char c = 'A';
printf("%d\n", c); / c는 승격이 일어나 int형이 됨 (65출력) /
7번, 8번, 10번, 17번