0% found this document useful (0 votes)
55 views2 pages

PW 2: Discovering The Environment 2: Goals

This document outlines exercises for a programming workshop that introduces students to programming in C under Unix. The exercises include: 1) writing a program to calculate integer powers of real numbers, 2) checking if a number is prime, 3) calculating statistics like average, min, and max on array data, 4) modifying a program from the previous workshop to make it case insensitive and allow spacing, 5) calculating days in a month and validating user input, and 6) modeling fixed rate investment returns over time.

Uploaded by

Nesrin Nesirova
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views2 pages

PW 2: Discovering The Environment 2: Goals

This document outlines exercises for a programming workshop that introduces students to programming in C under Unix. The exercises include: 1) writing a program to calculate integer powers of real numbers, 2) checking if a number is prime, 3) calculating statistics like average, min, and max on array data, 4) modifying a program from the previous workshop to make it case insensitive and allow spacing, 5) calculating days in a month and validating user input, and 6) modeling fixed rate investment returns over time.

Uploaded by

Nesrin Nesirova
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

UE 204 Introduction to Computer Science 2

PW 2: Discovering the environment 2


Goals

● Familiarize yourself with the C development environment under Unix


● Write a program using loops
● Start to test a program
● Introduction to arrays
● Practice the difference between Python and C

Exercise 1:

Calculate and display the integer power of a real.

Exercise 2:

Write a program that checks if a number entered by the user is a prime number or not.

Exercise 3: Array (should be done after 3rd IC session)

The objective of this exercise is to calculate some statistics on a series of real values.

The user should be asked to enter the size and elements of the array.

● Write a program that determines the average of the values in the array.
● In addition to the average, we want to know the smallest and the largest value of the series.

Exercise 4:

Refer to the program you wrote in Exercise 4 of PW1:

● Modify the program to allow unit entry in both lowercase and uppercase.
● Modify the program to allow the user to put blanks between the value and the unit.
● Modify the program so that, after the results are displayed, the program asks the user if they
want to start over. The program then stops if and only if the user types the character "n"
(upper or lower case).


UE 204 Introduction to Computer Science 2

Exercise 5:

Given the number of a month and a year read on the keyboard (the month must be between 1 and
12 and the year strictly positive), the following questions are asked to be answered.

● Calculate and display the number of days in this month. Leap years will be taken into account.

Note: A year is a leap year if it is a multiple of 4 without being a multiple of 100 unless it is a multiple
of 400. Thus, 2001 and 1900 are not leap years, whereas 2004 and 2000 are.

● Modify the program to verify the input. If the user enters an incorrect number, the program
should report it and prompt the user for a new month number.
● In addition to the number of days, display the name of the month in full.

Exercice 6: from your intro to cs1 course

With some capital, we want to assess the appropriateness of a fixed rate investment. The interest
rate is assumed to be fixed for the entire term of the investment (if the profit is around a certain
amount). It is also assumed that no transaction (credit or debit) is carried out on the account except
for the deposit of the initial capital and the addition of interest on the anniversary date of the
account.

Under these simplifying assumptions, we know that the interest earned during the year is the
product of the account balance at the start of the year and the interest rate. As the interest is
capitalized, it is the account balance plus interest acquired during the year that serves as the basis for
calculating interest for the following year.

1. Evolution of capital. Write a program which displays on each anniversary date of the
investment the capital and interest acquired during the last year (given: an initial capital, an
interest rate and an investment period entered by the user).
2. Double its initial capital. Write a program that, given an interest rate, displays the number of
years it takes to double the capital.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy