Starting from:

$25

IT1050 - Lab 01 - Solved

Objectives:   

•       Learn to use the Visual Studio 2015 platform.   

•       Use sequence, selection and repetition using the C programming language

Exercise 1: 

In Visual C++, create a new Win32 Console Application project.  Save the project in your Desktop. We will name the project as GreetingConsoleApp

Sign In to Visual Studio 

When you start Visual Studio for the first time, you are given the chance to sign in using a Microsoft account such as Live or Outlook. Signing in allows your settings to be synchronized across all your devices. For more information, see Signing in to Visual Studio 

Figure 1: Create a simple application 

When you create an app in Visual Studio, you first create a project and a solution. For this example, you’ll create a Windows console application.

To create a console app 
1)      On the menu bar, choose File, New, Project.

  

2)      In the Visual C++ category, choose the Win32 Console Application template, and then name the project GreetingConsoleApp.
3)      When the Win32 Application Wizard appears, choose the Finish button. 

4)      The GreetingsConsoleApp project and solution, with the basic files for a Win32 console app, are created and automatically loaded into Solution Explorer. The GreetingsConsoleApp.cpp file is opened in the code editor. The following items appear in Solution Explorer: Figure 4: Project items

  Add Code to the Application 

Next, you'll add code to display the word "Hello" in the console window.

To display “Hello” in the console window

In the GreetingsConsoleApp.cpp file, enter a blank line before the line return 0; and then enter the following code:

Since C++ is a superset of C commands, for this Lab we will write the code using the C programming language.

#include “stdafx.h” // This is there by default, lets ignore this 

#include <stdio.h> int main(void) {      printf(“Hello\n”);      char ch; 

     scanf(“%c”, &ch); // Without an input command visual studio                // runs the code and automatically returns to the editor      return 0; 



 

Compile and Run your Application 

Now you are ready to compile and run the program that you have written.  Select Start Debugging from the Debug Menu.

  

To clean the solution files that were created you can use the following command.  This is useful when you want to copy the project file that you have created and remove all unwanted files.

 
Reference : Getting Started with C++ in Visual Studio (https://msdn.microsoft.com/enus/library/jj620919.aspx) 

 

Exercise 2: 

Create a new Project and write a program to input a length in CMs.  Calculate and print the equivalent (same) length in inches.

1 inch = 2.54cm

  Exercise 3: 

Create a new Project and write a program to print a multiplication table of a given input. e.g.  

Enter Number : 5

5 x 1 = 5

5 x 2 = 10



5 x 12 = 60

 Exercise 4: 

 Create a new Project and write a program to implement the following functions.

int Square(int x) à X*X

int Cube(int x) à X*X*X

Write a main() function to call these two functions.

More products