๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
โœ’๏ธ C Programming/๋ˆ„๊ตฌ๋‚˜ ์‰ฝ๊ฒŒ ์ฆ๊ธฐ๋Š” C ์–ธ์–ด ์ฝ˜์„œํŠธ_๊ฐœ์ • 3ํŒ

[๋ˆ„๊ตฌ๋‚˜ ์‰ฝ๊ฒŒ ์ฆ๊ธฐ๋Š” C ์–ธ์–ด ์ฝ˜์„œํŠธ - ๊ฐœ์ • 3ํŒ] 2์žฅ Lab, Mini Project ๋ฌธ์ œ ํ’€์ด

by A Lim Han 2023. 1. 7.

# 2์žฅ Lab, Mini Project ๋ฌธ์ œ ํ’€์ด

 

 

72p_Lab)

#include <stdio.h>

int main()
{
	int first = 0;
	int second = 0;

	printf("์ฒซ ๋ฒˆ์งธ ์ˆซ์ž๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค: ");
	scanf_s("%d", &first);

	printf("๋‘ ๋ฒˆ์งธ ์ˆซ์ž๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค: ");
	scanf_s("%d", &second);

	int sum = first + second;
	int min = first - second;
	int mul = first * second;
	int div = first / second;

	printf("๋‘ ์ˆ˜์˜ ํ•ฉ: %d \n", sum);
	printf("๋‘ ์ˆ˜์˜ ์ฐจ: %d \n", min);
	printf("๋‘ ์ˆ˜์˜ ๊ณฑ: %d \n", mul);
	printf("๋‘ ์ˆ˜์˜ ๋ชซ: %d", div);

	return 0;
}

๊ธฐ๋ณธ

 

์‘์šฉ

 

 

 

 

74p_Mini Project)

#include <stdio.h>

int main()
{
	int how_many_days = 0;
	int flight_cost = 0;
	int hotel_cost = 0;
	int one_day_money = 0;

	printf("์—ฌํ–‰์€ ๋ช‡๋ฐ•์ธ๊ฐ€์š”?: ");
	scanf_s("%d", &how_many_days);

	printf("ํ•ญ๊ณต๊ถŒ ๊ฐ€๊ฒฉ: ");
	scanf_s("%d", &flight_cost);

	printf("ํ˜ธํ…” 1๋ฐ• ๊ฐ€๊ฒฉ: ");
	scanf_s("%d", &hotel_cost);

	printf("ํ•˜๋ฃจ์— ํ•„์š”ํ•œ ์šฉ๋ˆ: ");
	scanf_s("%d", &one_day_money);

	int total = how_many_days * hotel_cost + one_day_money * (how_many_days + 1) + flight_cost;

	printf("=============================\n");
	printf("์ด ์—ฌํ–‰ ๋น„์šฉ: %d \n", total);
	printf("=============================");

	return 0;
}