Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CSI2372 Fall 2019 Assignment #1 - C++ Basics, Assignments of Computer Science

Assignment #1 for the csi2372 - introduction to c++ course offered at the university of waterloo in fall 2019. The assignment covers the basics of c++ programming, including cout, cin, loops, function design, and operator usage. Students can complete the assignment individually or in teams of two. Instructions for five exercises, each with specific evaluation criteria.

Typology: Assignments

2020/2021

Uploaded on 07/14/2021

jinyi-pan
jinyi-pan 🇨🇦

1 document

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSI2372 Fall 2019
Assignment #1
Due Date: By 11:59 PM, Sunday, October 6th, 2019
Evaluation: 3% of final mark (see marking rubric at the end of handout)
Late Submission: none accepted
Purpose: The purpose of this assignment is to help you learn the C++ Basics, cout, cin /
loops, function design and its call, the use of operators and primitive types.
Teams: The assignment can be done individually or in teams of 2 students maximum.
Team members must be in the same lecture section. Submit one assignment per team;
be sure to have both team members’ name in the comments at the top of the assignment.
General Guidelines When Writing Programs:
- Include the following comments at the top of your source codes
// ------------------------------------------------------------------------------
// Assignment (include number)
// Written by: (include your name (s) and student id(s))
// For CSI2372 Section (your section) Fall 2019
// -----------------------------------------------------------------------------
pf3
pf4

Partial preview of the text

Download CSI2372 Fall 2019 Assignment #1 - C++ Basics and more Assignments Computer Science in PDF only on Docsity!

CSI2372 – Fall 2019

Assignment

Due Date: By 11:59 PM, Sunday, October 6th, 2019

Evaluation: 3% of final mark (see marking rubric at the end of handout)

Late Submission: none accepted

Purpose: The purpose of this assignment is to help you learn the C++ Basics, cout, cin / loops, function design and its call, the use of operators and primitive types.

Teams: The assignment can be done individually or in teams of 2 students maximum. Team members must be in the same lecture section. Submit one assignment per team; be sure to have both team members’ name in the comments at the top of the assignment.

General Guidelines When Writing Programs:

  • Include the following comments at the top of your source codes

// Assignment (include number)

// Written by: (include your name (s) and student id(s))

// For CSI2372 Section (your section) – Fall 2019 // -----------------------------------------------------------------------------

Exercise #1:

Rewrite the following C program in C ++ program. C ++ program must be compiled and tested with the number entered on the screen by the user and must display the correct result: #include <stdio.h>

int read_number(void) { int n; /* Read a number */ printf("Enter a number : "); scanf("%d", &n); return n; } void main() { int i, n; long total = 0;

n = read_number();

for (i = 1; i <= n; i++) { total += i; /* accumulation in the variable « total » */ printf("i = %d, total = %ld \n", i, total); }

printf("\n"); printf("*** Final Total = %ld *** \n", total); } /* end of main() */

Here is an example of the output of the C program given above:

Evaluation Criteria or Assignment #1 (25 points)

Source code

Question 1 (5 pts.)

Rewriting correctly C program to C++ program 3 pts.

Displaying the correct result 2 pts.

Question 2 (5 pts.)

Prompting user/reading data 1 pt.

Utilization of cin, cout and endl 1 pt.

Calculation of the formula 1 pt.

Displaying the result using variables values 2 pts.

Question 3 (5 pts.)

Prompting user/reading data 1 pt.

Utilization of cin, cout and endl 1 pt.

Utilization of while loop and an array to store the numbers 1 pt.

Displaying the result using variables values 2 pts.

Question 4 (5 pts.)

Prompting user/reading data 1 pt.

Utilization of cin, cout and endl 1 pt.

Utilization of while loop and an array to store the numbers 2 pt.

Displaying the result using variables values 1 pt.

Question 5 (5 pts.)

Prompting user/reading data 1 pt.

Utilization of cin, cout and endl 1 pt.

Designing the conversion() function 2 pt.

Displaying the result using variables values 1 pt.