開発環境
- Microsoft Windows 7 Home Premium (OS)
- Microsoft Visual C# 2010 Express Edition (IDE)
- 言語: C#
『初めてのC# 第2版』(Jesse Liberty+Brian MacDonald著、日向俊二訳、オライリー・ジャパン、2006年、ISBN978-487311-294-7)の 第4章(演算子)4.6(練習問題)練習4-1を解いてみる。
その他参考書籍
練習4-1.
コード
using System;
class Tester
{
public void Run()
{
int x = 25;
int y = 5;
Console.WriteLine("x = {0}, y = {1}", x, y);
Console.WriteLine("合計: {0}", x + y);
Console.WriteLine("差: {0}", x - y);
Console.WriteLine("積: {0}", x * y);
Console.WriteLine("商: {0}", x / y);
Console.WriteLine("モジュロ: {0}", x % y);
}
static void Main()
{
Tester t = new Tester();
t.Run();
}
}
入出力結果(Console Window)
x = 25, y = 5 合計: 30 差: 20 積: 125 商: 5 モジュロ: 0 続行するには何かキーを押してください . . .
0 コメント:
コメントを投稿