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

CS111 Week 2: IDE and Hello World

The document provides instructions for three programming exercises to introduce students to using an IDE: the first has students open and close the IDE to configure it, the second has them write a basic "Hello World" program, and the third has them write a program to print a welcome message and list of prices for beverages at a cafe.

Uploaded by

Rahul Narayan
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)
42 views2 pages

CS111 Week 2: IDE and Hello World

The document provides instructions for three programming exercises to introduce students to using an IDE: the first has students open and close the IDE to configure it, the second has them write a basic "Hello World" program, and the third has them write a program to print a welcome message and list of prices for beverages at a cafe.

Uploaded by

Rahul Narayan
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

CS111 – Tutorial/Laboratory – Week 2

Programming Exercise 2.1 - Introduction to the IDE


In this exercise, you are asked to start the IDE once and close it. The reason is to make sure
that it is configured correctly once. Closing it ensures that the configuration is stored for
future use.
1. Go to START and search for Dev-C++
2. Click on "Next" or "Yes" until the program completely starts
3. Exit the program.

Programming Exercise 2.2 - Hello World


Just about every programmer in the world has written the Hello World program. This
exercise will give you practice on writing your own Hello World program from scratch, get it
compiled and have it run.
1. Start Dev-C++. If it’s already open, close it and start it again.
2. Create a new source file and save it as hello. Remember that you don’t have to add
the extension .cpp. Dev will automatically add it to the file name.
3. Delete all the code that is in the text editor window.
4. In its place, type the following C++ code. Don’t worry about the details of the
program. Just type it exactly as it is:

// Hello World Program


#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World!\n";
return 0;
}
Note, that as you typed, the 2 lines between the braces { } are indented automatically!
5. It is good practice to continually save your work – just in case you accidentally
overwrite an hour’s work. Save by clicking Save in the File menu or use the shortcut
CTRL-S, best after every line of typing. You will regret any saving laziness – trust me!
6. Once you have entered your source code, compile it.
7. If any errors are reported, see the compiler error pane by clicking the compiler tab.
Double-clicking any error will take you to the line of your program that contains the
error. Try to correct all the compiler errors in the edit pane, then re-compile the
code.
8. If there are no errors, go ahead and execute your program.
9. Finally, add a 2nd comment line with your name and the current date. Re-compile.
Programming Exercise 2.3 - Welcome Message
Write a program that prints a welcome message to screen for customers of the
Programmers’ Café (see the case study below). The message should say what customers can
buy and perhaps print a list with prices. If you have problems with formatting or compiling
ask your tutor or your neighbour.
Save this program in a file called [Link] on your USB drive. You will continue
working on this program for the next few weeks.

Case Study.
Design a console-based order-processing program for the Programmers’ Café.
Programmers’ Café is a locally owned and operated coffee house with the finest beverage
selection in the country. It offers beverages made from the finest ingredients. Currently, it
serves the following beverages:

Beverage Regular Large Extra Large


Long Black $3.50 $3.70 $4.00
Flat White $3.80 $4.20 $4.50
Cappuccino $4.00 $4.30 $5.00
Tea $3.00 $3.20 $3.50

Common questions

Powered by AI

From a customer's perspective, benefits include faster and more accurate order processing and potentially customized service. For the business, such a program can enhance operational efficiency, reduce human error, provide better inventory tracking, simplify data analysis on sales patterns, and facilitate strategic decision-making through comprehensive data collection .

Writing and executing a 'Hello World' program is significant because it provides basic practice in writing code, understanding the structure of a C++ program, and using an IDE effectively. According to the exercise, you create a new source file as 'hello', input specified C++ code, save and compile the program, and then run it if no errors occur. You revisit the code to add personal comments, recompile, and finalize the program with 'cout<<"Hello World!\n";' .

Adding personalized comments helps by documenting the purpose and functionality of code segments, improving collaborative work by explaining logic to others, serving as reminders for the original programmer for future reference, and aiding in debugging by allowing programmers to understand their own logic and thought process over time .

Continuously saving your work ensures that no progress is lost due to accidental overwriting or system errors. This practice is critical because it prevents the loss of significant effort and encourages developers to regularly reflect on their progress, making it easier to roll back changes if necessary .

The instructions involve starting and closing the IDE to ensure it's configured for future sessions. These steps are necessary because they help confirm that the environment variables and settings are correctly initialized, which is essential for seamless programming workflows and avoiding issues related to misconfiguration .

The exercise suggests that when compiler errors are reported, you should view them in the compiler error pane, double-click any error to locate it in the source code, and attempt to correct it before recompiling. This process is important as it develops problem-solving skills, helps understand the syntax and functionality of a programming language more deeply, and ensures the code runs correctly .

The steps include creating a new source file and writing the code, saving the work regularly, compiling the program to check for errors, using the compiler error pane to debug any issues, and then executing the program if no errors remain. Re-compilation may be required after adding or modifying existing code .

To configure and utilize the IDE, you need to start the IDE and then close it to ensure the configuration is stored for future use. You start by searching for Dev-C++ in the Start menu, click through prompts until the program starts, and finally exit the program .

The Programmers’ Café offers Long Black ($3.50 Regular, $3.70 Large, $4.00 Extra Large), Flat White ($3.80 Regular, $4.20 Large, $4.50 Extra Large), Cappuccino ($4.00 Regular, $4.30 Large, $5.00 Extra Large), and Tea ($3.00 Regular, $3.20 Large, $3.50 Extra Large).

You're expected to develop a console-based order-processing program for the Programmers’ Café. The program should print a welcome message to the screen, inform customers about the beverages available, and possibly display a list with prices. The program is iterative, allowing you to continuously improve it over time .

You might also like