๐Ÿ‘ฉ‍๐Ÿ’ป ์•Œ๊ณ ๋ฆฌ์ฆ˜/๐Ÿ”  C

[๋‚˜๋„์ฝ”๋”ฉ C์–ธ์–ด ๋ฌด๋ฃŒ ๊ฐ•์˜] ํ”„๋กœ์ ํŠธ 1

์˜ค๋ธŒ ๐Ÿง™‍โ™‚๏ธ 2023. 7. 26. 19:01

์ •์ˆ˜ํ˜• ๋ณ€์ˆ˜๋Š” %d

์‹ค์ˆ˜ํ˜• ๋ณ€์ˆ˜๋Š” %f

๋ฌธ์ž ํ•˜๋‚˜๋Š” %c

๋ฌธ์ž์—ด์€ %s

 

๋ฌธ์ž์—ด์€ (%s, str , sizeof(str))

#include <stdio.h>
int main()
{
	//์ •์ˆ˜ํ˜• ๋ณ€์ˆ˜
	/*int age = 12;
	printf("%d\n",age);
	age = 13;
	printf("%d\n", age);*/
		
	//์‹ค์ˆ˜ํ˜• ๋ณ€์ˆ˜
	/*float f = 46.5f;
	printf("%.2f\n", f);
	double d = 4.428;
	printf("%.2lf\n", d);
	const int YEAR = 2000;
	printf("ํƒœ์–ด๋‚œ ๋…„๋„ : %d\n", YEAR);*/

	/*int add = 3 + 7;
	printf("3+7 = %d\n", add);
	printf("%d + %d = %d\n", 30, 79, 30 + 79);

	int input;
	printf("๊ฐ’์„ ์ž…๋ ฅํ•˜์„ธ์š” :  ");
	scanf_s("%d", &input);
	printf("์ž…๋ ฅ๊ฐ’ : %d\n", input);*/
	
	/*int one, two, three;
	printf("3๊ฐœ์˜ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”: ");
	scanf_s("%d %d %d", &one, &two, &three);
	printf("์ฒซ ๋ฒˆ์งธ ๊ฐ’ : %d\n ", one);
	printf("๋‘ ๋ฒˆ์งธ ๊ฐ’ : %d\n ", two);
	printf("์„ธ ๋ฒˆ์งธ ๊ฐ’ : %d\n ", three);
	
	char a = 'q';
	printf("%c\n", a);

	char str[256];
	scanf_s("%s", str, sizeof(str));
	printf("%s\n", str);*/

	//ํ”„๋กœ์ ํŠธ
	//๊ฒฝ์ฐฐ๊ด€์ด ๋ฒ”์ฃ„์ž์˜ ์ •๋ณด๋ฅผ ์ž…์ˆ˜

	char name[256];
	printf("์ด๋ฆ„์ด ๋ญ์˜ˆ์š”? : ");
	scanf_s("%s", name, sizeof(name));

	int age;
	printf("๋ช‡์‚ด์ด์˜ˆ์š”? : ");
	scanf_s("%d", &age);

	float weight;
	printf("๋ช‡kg์—์š”?: ");
	scanf_s("%f", &weight);

	double height;
	printf("ํ‚ค๊ฐ€ ๋ช‡ cm์—์š”? : ");
	scanf_s("%lf", &height);

	char what[256];
	printf("๋ฌด์Šจ ์ฃ„๋ฅผ ์ง€์—ˆ์–ด์š”? : ");
	scanf_s("%s", what, sizeof(what));

	//์กฐ์‚ฌ๋‚ด์šฉ์ถœ๋ ฅ

	printf("\n\n~~~๋ฒ”์ฃ„์ž ์ •๋ณด~~~\n\n");
	printf("์ด๋ฆ„           : %s\n", name);
	printf("๋‚˜์ด           : %d\n", age);
	printf("๋ชธ๋ฌด๊ฒŒ         : %.2f\n", weight);
	printf("ํ‚ค             : %.2lf\n", height);
	printf("๋ฒ”์ฃ„๋ช…         : % s\n", what);

	return 0;



	
}