LoginSignup
10
7

More than 5 years have passed since last update.

15 Exercises for Learning a new Programming Language

Last updated at Posted at 2015-11-02

(1)

  • Display series of numbers (1,2,3,4, 5....etc) in an infinite loop. The program should quit if someone hits a specific key (Say ESCAPE key).
  • 無限ループで1,2,3...と順番にカウントする。何かキーが押されたら、プログラムを終了させる。

(2)

  • Fibonacci series, swapping two variables, finding maximum/minimum among a list of numbers.
  • フィボナッチ数列を表示する。二つの数字を入れ替える。数のリストの中から最大値と最小値を見つける。

(3)

  • Accepting series of numbers, strings from keyboard and sorting them ascending, descending order.
  • キーボードから数字や文字列のリストを入力し、降順、昇順でソートする。

(4)

  • Reynolds number is calculated using formula (D*v*rho)/mu Where D = Diameter, V= velocity, rho = density mu = viscosity. Write a program that will accept all values in appropriate units (Don't worry about unit conversion) If number is < 2100, display Laminar flow, If its between 2100 and 4000 display 'Transient flow' and if more than '4000', display 'Turbulent Flow' (If, else, then...)
  • レイノルド数を下記公式を使用して計算する。全ての数字の単位は適切なものが入力されるとする。(単位変換はケアしなくてよい)もし計算結果のレイノルド数が2100未満ならば"Laminar flow"、2100から4000の間であれば"Transient flow"、4000以上であれば"Turbulent flow"と表示する。
  • D*V*rho/mu, where D=Diameter, V=Velocity, rho=density, mu=viscosity(粘度)

(5)

  • Modify the above program such that it will ask for 'Do you want to calculate again (y/n), if you say 'y', it'll again ask the parameters. If 'n', it'll exit. (Do while loop)While running the program give value mu = 0. See what happens. Does it give 'DIVIDE BY ZERO' error? Does it give 'Segmentation fault..core dump?'. How to handle this situation. Is there something built in the language itself? (Exception Handling)
  • 上記プログラムを次のように修正する。"Do you want to calculate again (y/n)"と表示し、もしyが押されたら、次にパラメータをたずねる。もし、nが押されたら終了する。もし、プログラムの動作中に、mu=0が入力されたらどのようなことがおこるか確認し(0除算エラーかもしくはセグメンテーションフォールトか。)、エラーを適切に処理する。

(6)

  • Scientific calculator supporting addition, subtraction, multiplication, division, square-root, square, cube, sin, cos, tan, Factorial, inverse, modulus
  • 関数電卓を作る。(足し算、引き算、掛け算、割り算、平方根、3乗根、サイン、コサイン、タンジェント、階乗、反数、剰余)

(7)

  • Printing output in different formats (say rounding up to 5 decimal places, truncating after 4 decimal places, padding zeros to the right and left, right and left justification)(Input output operations)
  • いろいろなフォーマットでの出力(小数点5位で丸め、小数点4位以下を切り捨て、右もしくは左を0埋め、右もしくは左寄せ)

(8)

  • Open a text file and convert it into HTML file. (File operations/Strings)
  • テキストファイルを開いて、HTMLファイルに変換する。

(9)

  • Time and Date : Get system time and convert it in different formats 'DD-MON-YYYY', 'mm-dd-yyyy', 'dd/mm/yy' etc.
  • システム時間を取得して、異なったフォーマットに変換する。('DD-MON-YYYY', 'mm-dd-yyyy', 'dd/mm/yy' etc.)

(10)

  • Create files with date and time stamp appended to the name
  • ファイルネームに日時とタイムスタンプを付与したファイルを作成する。

(11)

  • Input is HTML table, Remove all tags and put data in a comma/tab separated file.
  • HTMLテーブルを入力。タグを削除し、データをコンマもしくはタブで分割してファイルを作成する。

(12)

  • Extract uppercase words from a file, extract unique words
  • ファイルから大文字や重複の無い単語の抽出

(13)

  • Implement word wrapping feature (Observe how word wrap works in windows 'notepad')
  • 単語の折り返し機能の実装。(Windowsのメモ帳参照)

(14)

  • Adding/removing items in the beginning, middle and end of the array.
  • 配列の先頭、真ん中もしくは末尾からアイテムを追加もしくは削除する。

(15)

  • Are these features supported by your language: Operator overloading, virtual functions, references, pointers etc.Is there something called 'namespace / package / module' supported by your language?
  • あなたが使用している言語でこれらの機能はサポートされていますか?
10
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
7