Basic C programming: Final assignments¶

Yuto Omae @ Nihon University, Japan¶

  • We use online c compiler.
  • https://www.onlinegdb.com/online_c_compiler

Assignment 1:¶

  • Five patients arrive at the hospital.
  • They input (1) first name, (2) last name, (3) age, (4) gender, (5) height, and (6) weight from a keyboard by scanf.
  • Including calculation function of BMI.
  • Show averge value of BMI in a display.
  • Show the numbers of male/female in a display.
  • Show the numbers of person who is over 25 BMI in a display.
  • Save (1)-(6), and (7) BMI of all patient to array-type variables.
  • Output files on the above arrays, e.g., first_name.csv, lase_name.csv, age.csv ...

Submission:

  • (1) The code file code_a1.c that can run in https://www.onlinegdb.com/online_c_compiler.

Assignment 2:¶

NPC and a user play the Rock-Paper-Scissors game.

Rule:

  • NPC and a user select one in Rock-Paper-Scissors at same timing.
  • Rock is stronger than Scissors.
  • Paper is stronger than Rock.
  • Scissors is stronger than Paper.
  • For example, when NPC selects Scissors and a user selects Rock, a user win.
  • When selections of NPC and a user is same, no winner and no loser.

System:

  • NPC selects a choice randomly from Rock-Paper-Scissors.
  • A user selects a choice from keyboard by scanf.
  • The number of games is five times.
  • Record the results of win or lose of each game in array-type variable, and output it as a CSV file Game_Result.csv.
  • User win: 1, user lose: -1, no win and no lose (same choice): 0

Submission:

  • (1) The code file code_a2.c that can run in https://www.onlinegdb.com/online_c_compiler.

Assignment 3:¶

Develop a practical system by using C programming. Include the follows.

  • Conditional branch (use If statement)
  • Repeating process (use While and/or For statement)
  • Input values from keyboard (use scanf function)
  • Any user-defined function(s)
  • Output values as CSV file

Submission:

  • (1) The code file code_a3.c that can run in https://www.onlinegdb.com/online_c_compiler.
  • (2) The PDF file code_a3_explanation.pdf that includes explanation of your system.