Chlln's Code/C#(4)
-
[C#] 03 : 연습 문제
문제 1 다음과 같이 사용자로부터 사각형의 너비와 높이를 입력받아 넓이를 계산하는 프로그램을 완성하세요. [출력 예시] 사각형의 너비를 입력하세요. 30 사각형의 높이를 입력하세요. 40 사각형의 넓이는 : 1200 Ch03/Q01/Program.cs using System; namespace RectArea { class Program { public static void Main() { Console.Write("사각형의 너비를 입력하세요. : "); string width = Console.ReadLine(); Console.Write("사각형의 높이를 입력하세요. : "); string height = Console.ReadLine(); double area = double.Parse(width)..
2023.03.16 -
[C#] 03 : 데이터 보관하기
기본 데이터 형식 Ch03/IntegralType/MainApp.cs using System; namespace IntegralTypes { class MainApp { static void Main(string[] args) { sbyte a = -10; byte b = 40; Console.WriteLine($"a = {a}, b = {b}"); short c = -30000; ushort d = 60000; Console.WriteLine($"c = {c}, d = {d}"); int e = -1000_0000; // 0이 7개 uint f = 3_0000_0000; // 0이 8개 Console.WriteLine($"e = {e}, f = {f}"); long g = -5000_0000_0000;..
2023.03.16 -
[C#] 02 : 연습 문제
문제 1 다음과 같이 텍스트를 출력하는 프로그램을 작성하세요. 여러분, 안녕하세요? 반갑습니다! Ch02/Q01/MainApp.cs using System; using static System.Console; namespace Q01 { class MainApp { static void Main(string[] args) { WriteLine("여러분 안녕하세요?\n반갑습니다!"); } } } 출력 결과 여러분 안녕하세요? 반갑습니다! 문제 2 아래 실행 결과를 출력할 수 있도록 다음 코드에서 [ 1 ]과 [ 2 ]에 필요한 코드를 채우세요. using [ 1 ]; class MainApp{ static void Main(string[] args) { [ 2 ].WriteLine("Hello World!..
2023.03.16 -
[C#] 02 : 처음 만드는 C# 프로그램
Hello, World! Ch02/HelloWorld/MainApp.cs using System; using static System.Console; namespace Hello { class MainApp { // 프로그램 실행이 시작되는 곳 static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("사용법 : Hello.exe "); return; } WriteLine("Hello, {0}!", args[0]); } } } 출력 결과 입력 : HelloWorld Chlln 출력 : Hello, Chlln!
2023.03.16