You are on page 1of 3

CPSC 253u Project 2

Introduction There are four activities in this one project: One C++ program One C program One Wine program Knowledge of file permissions

Activity 1 Make a C++ program and compile it with the GNU compiler. Here is what your program must do. 1. Display a welcome message 2. Ask to input an integer 3. Ask to input another integer 4. Compute the sum of the two integers. 5. Out the sum with an explanatory message. 6. Display a good bye message. Compile the program with the GNU compiler. It is known as g++ in the terminal window. Run the program and test it.

Activity 2 Some engineers and technicians prefer plain C language. C language is more simple that C+ +, and some people say that it is more robust and powerful than C++. Make a C program that does the following. 1. 2. 3. 4. Display a welcome message. Ask for input of one positive integer. The program displays all the divisors of that integer beginning with number 1. Display a good-bye message.

Sample run Welcome to John's divisor program. Please enter an integer: 36 The divisors are: 1 2 3 4 6 9 12 18 36 Have a nice day.

In a C program do not include <iostream> because that belongs to C++. In C you should have a statement like this: #include <stdio.h> In C you will output with the printf statement. Compile your program with the GNU C compiler. It is known as gcc in the terminal window. Run the program and test it.

Activity 3 Windows programs do not run in Linux unless you do something special to make it happen. Now you will make it happen. First use your package manager to install Wine. When Wine has finished installing it will bring with it the program Notepad. Notepad is a Windows program, but Wine makes it work in Linux. Then go to the Wine website and look at the names of windows programs that receive a high rating. You have to find a Windows program with a good rating that you already own. Maybe it is a game, or maybe it is a paintbrush program. Anything made for windows is acceptable. Now make Wine run your program in Linux.

Activity 4 You need to know about file permissions. Every file in Linux has 9 file permission. Open the terminal window and enter the command ls -l without the quotes. Each file in the folder will be listed like the following.
-rw--wxr-x 1 activeprofessor activeprofessor 34 2010-12-20 13:13 myfile.asm

The permissions for this file named myfile.asm are given at the far left side. In this case the permissions are r w - - w x r - x . On the first day of this semester you obtain an electronic copy of a Linux book. Refer to pages 348 355 to learn about file permissions. Here is your job. Make a special folder with the name activity4 . Put into this folders some files. It doesn't matter which files you put into the folders. Make sure there is one file with each of the following different permissions. rwxrx wrxr xrwxrw rxrrx wrwxrwx xrxx

rxrw So, you need 7 files in that folder called activity4. One file has one set of permissions. Prove that you set all the permissions correctly by entering the command ls -l without quotes. Consider the last file on the list above. It has permissions rxrw . The command rm without quotes is the delete command. Use the rm command to try to delete the file. Probably Linux will not let you delete that file. The reason is that you don't have permission to delete it. Give yourself administrative permission to delete the file. Use the sudo command combined with rm to become administrator, and then you will be allowed to delete that file. Get credit for this project. Bring your computer with Ubuntu installed. Demonstrate to the professor the following activities. Activity 1. Compile and run your C++ program. Make sure it is free from errors before you come to the classroom Activity 2. Compile and run your C program. Come prepared. Activity 3. Run your windows program. Don't use notepad. Activity 4. Have ready your folder with 7 files with 7 different sets of permissions. Show all the files with the ls -l command. Show how to become administrator in order to remove the file where permissions begin with 3 minus signs. If you come prepared you should be able to demonstrate all four activities in 4 minutes or less. Due date: The tenth Saturday of the semester: 2011-March 26 Due date for third project: Fifteenth Saturday: 2011-May-7

You might also like