0% found this document useful (0 votes)
21 views

Data Structures Lab Exercise # 1 (C++ Basics) : Task 1: Basic Input/output (0.2 Points)

The document contains 3 tasks for a C++ lab exercise on data structures basics. Task 1 involves writing a program to convert Celsius to Fahrenheit. Task 2 involves calculating electricity bill costs based on usage. Task 3 contains 3 subtasks: display largest number and its frequency without arrays, check if a number is prime, and count prime numbers below a given number.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Data Structures Lab Exercise # 1 (C++ Basics) : Task 1: Basic Input/output (0.2 Points)

The document contains 3 tasks for a C++ lab exercise on data structures basics. Task 1 involves writing a program to convert Celsius to Fahrenheit. Task 2 involves calculating electricity bill costs based on usage. Task 3 contains 3 subtasks: display largest number and its frequency without arrays, check if a number is prime, and count prime numbers below a given number.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Data Structures

Lab Exercise # 1 (C++ basics)

Task 1: Basic Input/output (0.2 Points)


Write a C++ Program which asks the user to input the value of Temperature in
Celsius. The program then converts the temperature from Celsius to Fahrenheit.
Formula to convert from Celsius to Fahrenheit is: F = C x 9/5 + 32

Task 2: Selection Structures (0.5 Points)


Write a program that calculates the cost of Electricity bill for a given month period.
The program should take as input, the current and the previous (last month’s)
readings of the electricity meter. The number of units consumed in a month is the
difference between the current meter reading and the previous meter reading.
• The program should calculate the cost of the electricity bill using following
formula:
– The First one hundred units will cost 10 fils per unit.
– The next one hundred units will cost 20 fils per unit.
– The next three hundred units will cost 50 fils per unit.
– 500 onwards the cost of each unit will be 1AED (100 fils)
• The Program should print the cost of bill in Dirhams.

Task 3: Repetitive Structures (0.3 Points)


a) Write a program that asks the user to enter 10 integers (one by one), the program
then displays the largest number and its frequency in the entered set. You can use
only a single loop and 3 variables (in addition to the loop counter variable) to store
the information. You are not allowed to use arrays.
b) Write a program that asks the user to enter a number N. The program should verify if
N is a prime number or not?
c) Write a program that asks the user to enter an integer number N, then displays the
number(count) of prime numbers that are smaller than N.

Code of Conduct

All assignments are graded, meaning we expect you to adhere to the academic integrity standards of NYU
Abu Dhabi. To avoid any confusion regarding this, we will briefly state what is and isn’t allowed when working
on an assignment/lab-task.

Any documents and program code that you submit must be fully written by yourself. You can, of course, discuss
your ideas with fellow students, as long as these discussions are restricted to general solution techniques. Put
differently, these discussions should not be about concrete code you are writing, nor about specific results you
wish to submit. When discussing an assignment with others, this should never lead to you possessing the
complete or partial solution of others, regardless of whether the solution is in paper or digital form, and
independent of who made the solution, meaning you are also not allowed to possess solutions by someone
from a different year or course, by someone from another university, or code from the Internet, etc. This also
implies that there is never a valid reason to share your code with fellow students, and that there is no valid
reason to publish your code online in any form.

Every student is responsible for the work they submit. If there is any doubt during the grading about whether
a student created the assignment themselves (e.g. if the solution matches that of others), we reserve the
option to let the student explain why this is the case. In case doubts remain, or we decide to directly escalate
the issue, the suspected violations will be reported to the academic administration according to the policies of
NYU Abu Dhabi.

(see https://students.nyuad.nyu.edu/campus-life/community-standards/policies/academic-integrity/ )

You might also like