http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&sca=1020
JUNGOL
www.jungol.co.kr
사이트에서 직접 프로그램을 돌려볼 수 있습니다.
교재 P.36 연습문제1
#include <stdio.h>
int main(){
int a;
char b;
a = 10;
b = 'A';
printf("a = %d \n", a);
printf("b = %c \n", b);
return 0;
}
교재 P.36 자가진단1
#include <stdio.h>
int main(){
int a = -100;
printf("%d", a);
return 0;
}
교재 P.39 연습문제2
#include <stdio.h>
int main(){
int a, b;
a= 10, b=20;
printf("%d %d\n", b, a);
return 0;
}
교재 P.40 자가진단2
#include <stdio.h>
int main(){
int a=-1, b=100;
printf("%d\n", a);
printf("%d\n", b);
return 0;
}
교재 P.41 연습문제3
#include <stdio.h>
int main(){
int a, b;
a = 10;
b = 20;
printf("%d + %d = %d\n", a, b, a+b);
a = 30;
b = 40;
printf("%d + %d = %d\n", a, b, a+b);
}
교재 P.42 자가진단3
#include <stdio.h>
int main(){
int a, b;
a = 55, b = 10;
printf("%d - %d = %d\n", a, b, a-b);
a = 2008, b=1999;
printf("%d - %d = %d", a, b, a-b);
return 0;
}
교재 P.42 연습문제4
#include <stdio.h>
int main(){
int r = 5;
double pi = 3.14;
printf("원주 = %d * 2 * %f = %f \n", r, pi, r * 2 * pi);
printf("넓이 = %d * %d * %f = %f \n", r, r, pi, r * r * pi);
return 0;
}
교재 P.43 자가진단4
#include <stdio.h>
int main(){
int weight = 49;
double rate = 0.2683;
printf("%d * %lf = %lf", weight, rate, weight*rate);
return 0;
}
교재 P.44 연습문제5
#include <stdio.h>
int main(){
double x = 1.234;
double y = 10.3459;
printf("전체 7자리로 맞추고 소수 4자리까지 출력 \n");
printf("x = %7.4f \n", x);
printf("y = %7.4f \n", y);
printf("\n");
printf("소수 2자리까지 출력(반올림) \n");
printf("x = %.2f \n", x);
printf("y = %.2f \n", y);
return 0;
}
교재 P.45 자가진단5
#include <stdio.h>
int main(){
float yd1, inch1;
yd1 = 2.1;
inch1 = 10.5;
printf("%4.1fyd = %5.1fcm \n", yd1, yd1 * 91.44);
printf("%4.1fin = %5.1fcm", inch1, inch1 * 2.54);
return 0;
}
// 저는 단위랑 변수가 헷갈리지 않게 하기 위해 변수 뒤에 1을 작성하였습니다.
교재 P.46 연습문제6
#include <stdio.h>
int main(){
int age;
printf("당신의 나이는 몇 살입니까? ");
scanf("%d", &age);
printf("당신의 나이는 %d살이군요. \n", age);
return 0;
}
교재 P.47 자가진단6
#include <stdio.h>
int main(){
int height;
scanf("%d", &height);
printf("height = Your height is %dcm.", height);
return 0;
}
교재 P.47 연습문제7
#include <stdio.h>
int main(){
int a, b;
printf("두 수를 입력하시오. ");
scanf("%d %d", &a, &b);
printf("%d + %d = %d \n", a, b, a+b);
printf("%d * %d = %d \n", a, b, a*b);
return 0;
}
교재 P.48 자가진단7
#include <stdio.h>
int main(){
int a, b;
scanf("%d %d", &a, &b);
printf("%d * %d = %d \n", a, b, a*b);
printf("%d / %d = %d \n", a, b, a/b);
return 0;
}
교재 P.49 연습문제8
#include <stdio.h>
int main(){
int height;
double weight;
char name;
printf("키를 입력하세요. ");
scanf("%d", &height);
printf("몸무게를 입력하세요. ");
scanf("%lf", &weight);
printf("이름을 입력하세요. ");
scanf(" %c", &name);
printf("키 = %d \n", height);
printf("몸무게 = %.1f\n", weight);
printf("이름 = %c \n", name);
return 0;
}
교재 P.50 자가진단8
#include <stdio.h>
int main(){
double a, b;
char c;
scanf("%lf", &a);
scanf("%lf", &b);
scanf(" %c", &c);
printf("%.2lf \n", a);
printf("%.2lf \n", b);
printf("%c", c);
return 0;
}
교재 P.51 연습문제9
#include <stdio.h>
int main(){
double x, y;
printf("두 개의 실수를 입력하시오.\n");
scanf("%lf %lf", &x, &y);
printf("x = %.2f \n", x);
printf("y = %.2f \n", y);
return 0;
}
교재 P.52 자가진단9
#include <stdio.h>
int main(){
double a, b, c;
scanf("%lf %lf %lf", &a, &b, &c);
printf("%.3lf \n", a);
printf("%.3lf \n", b);
printf("%.3lf \n", c);
return 0;
}
'C언어(자기주도C언어프로그래밍) > Chapter02. 입력' 카테고리의 다른 글
자기주도C언어프로그래밍 Chapter02. 입력 - 형성평가 (0) | 2023.02.19 |
---|