함수
Synatx error
란 문법 에러를 의미한다.
I'm love you.
printf("hello, world\n")
Semantic error
란 문법 상의 오류는 없지만 그 내용에 논리적 모순이 있는 것을 의미한다.
My father is younger than me.
if (x == 0)
if (y == 0)
error();
else {
z = x + y;
f (&z);
}
#include <stdio.h>
int main(void)
{
int s;
s = 56;
printf("1년은 %d 주에 해당한다", s);
return 0;
}
Baa Baa Baa Black Sheep.Have you any wool?
<newline>
Begone!
0 creature of lard!
What?
No
fish?
<newline>
2 + 2 = 4
int
와 char
words
와 lines
의 값을 어떻게 출력시켜야 결과가 다음과 같은 형식으로 나타나게 될까? 여기서 두 변수의 값은 각각 3020 과 350 이다.There were 3020 words and 350 lines.
printf("There were %d words and %d lines\n", words, lines);
a = 5
b = 5
x = 150
y = 15
#include <stdio.h>
int main(void)
{
printf("문연수\n");
printf("문\n연수\n");
printf("문"); printf("연수\n");
return 0;
}
#include <stdio.h>
int main(void)
{
printf("이름: 문연수\n");
printf("주소: 전라북도 전주시 완산구 효자동 3가 1722-10번지 하남해비치 205호\n");
return 0;
}
#include <stdio.h>
int main(void)
{
int year, month, day;
int year_now = 2022;
int total;
year = 2000; month = 11; day = 30;
total = (year_now - (year + 1)) * 365
+ ((12 - month) * 30)
+ (30 - day);
printf("year: %d\tmonth: %d\n",
year_now - year, total);
return 0;
}
#include <stdio.h>
void jolly_good(void);
void deny(void);
int main(void)
{
jolly_good(); jolly_good(); jolly_good(); jolly_good();
deny();
return 0;
}
void jolly(void)
{
printf("For he's a jolly good fellow!\n");
}
void deny(void)
{
printf("Which nobody can deny!\n");
}
#include <stdio.h>
void br(void);
void ic(void);
int main(void)
{
br(); printf(","); ic(); printf("\n");
ic(); printf(",\n");
br(); printf("\n");
return 0;
}
void br(void)
{
printf("Brazil, Russia");
}
void ic(void)
{
printf("India, China");
}
#include <stdio.h>
int main(void)
{
int toes = 10;
printf("toes: %d\tsquare of toes: %d\tmultiple of toes: %d\n",
toes, toes * toes, toes * 2);
return 0;
}
#include <stdio.h>
void smile(void)
{
printf("Smile!");
}
int main(void)
{
smile(); smile(); smile(); printf("\n");
smile(); smile(); printf("\n");
smile(); printf("\n");
return 0;
}
#include <stdio.h>
void two(void)
{
printf("two\n");
}
void one_three(void)
{
printf("one\n");
two();
printf("three\n");
}
int main(void)
{
printf("starting now:\n");
one_three();
printf("done!\n");
return 0;
}