Docsity

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

Toggle sidebar
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.