Proj 17: Compiling C on Windows 2016 Server (15 pts)

What You Need

Purpose

You will write a small C program and compile it.

Downloading and Installing Visual C++ Build Tools

Open this page:

https://visualstudio.microsoft.com/visual-cpp-build-tools/

Click the "Download Build Tools" button, as shown below.

On the next page, in the "Build Tools for Visual Studio 2017" section, click the Download button, as shown below.

Save the vs_buildtools__935747363.1537797301.exe file in your Downloads folder.

Double-click the the vs_buildtools__935747363.1537797301.exe file.

A box pops up, as shown below.

Click Continue.

Wait while software downloads and installs, as shown below.

A large window appears, as shown below.

At the top left, click "Visual C++ build tools".

Click the Install button.

Wait while software downloads and installs., as shown below.

When the installation completes, you should see the screen shown below.

Click Launch. A Developer Command Prompt window opens, as shown below.

Hello, World in C++

In the Developer Command Prompt window, execute these commands:
mkdir c:\hello
cd c:\hello
notepad hello.cpp
A box pops up, asking "Do you want to create a new file?". Click Yes.

Enter this code, as shown below:

#include <iostream>  
using namespace std;  
void main()  
{  
    cout << "Hello, world!" << endl;  
}  

In Notepad, click File, Save.

In the Developer Command Prompt window, execute these commands:

cl /EHsc hello.cpp
hello
The program runs, and prints out "Hello, world!", as shown below.

Secret Number

In the Developer Command Prompt window, execute these commands:
cd c:\hello
notepad secretnum.cpp
A box pops up, asking "Do you want to create a new file?". Click Yes.

Enter this code, as shown below:

#include <iostream>  
using namespace std;  
void main()  
{
    int x[6] = {21, 49, 917,7777,82,9873 };
    int i, r;
    r = 255;
    for (i=0; i<6; i++)
       {
       	r = (r ^ x[i]) <<2;
       }
      
    cout << r << endl;  
}  

In Notepad, click File, Save.

In the Developer Command Prompt window, execute these commands:

cl /EHsc secretnum.cpp
secretnum
The program runs, and prints out a secret number, covered by a green box in the image below.

17. Recording Your Success (15 pts)

Use the form below to record your score in Canvas.

If you don't have a Canvas account, see the instructions here.

Name or Email:
Secret number (redacted in the image above):


Posted: 10-2-18