Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

Department of Computing

CS100: Fundamentals of ICT

Class: BEEnv2017

Lab 10: Introduction to Basic Programming

Date: 23-11-2017

Time: 02:00 pm – 05:00 pm

Instructor: Dr Hassan Khaliq

Fundamental of ICT Page 1


Lab 10: Introduction to Basic Programming

Objective

Computer programming (often shortened to programming) is the comprehensive process that


leads from an original formulation of a computing problem to executable programs. It involves
activities such as analysis, understanding, and generically solving such problems resulting in an
algorithm, verification of requirements of the algorithm including its correctness and its resource
consumption, implementation (or coding) of the algorithm in a target programming language,
testing, debugging, and maintaining the source code, implementation of the build system and
management of derived artefacts such as machine code of computer programs.

Description

This lab is about executing programs using Microsoft Visual studio 2010.

Getting Starting with Visual Studio 2010

Step 1: Click on start button and select “All Programs”

Fundamental of ICT Page 2


Step 2: Select Microsoft Visual Studio 2008/2010/2013/2017. Here the instructions are given visual
studio 2010 as an example.

Step 3: After selecting Microsoft Visual Studio 2010 folder there will be again an option of Microsoft
Visual Studio 2010.

Step 4: After selection of Microsoft Visual Studio 2010 a screen like this will be shown.

Fundamental of ICT Page 3


Fundamental of ICT Page 4
Step 5: Now to create a project select “New” from “File” menu and choose “Project”.

Step 6: In the New Project dialog box select Visual C++ from the left most column and Win32 Console
Application from the central column. On the bottom give the name of the project and click OK.

Fundamental of ICT Page 5


Step 7: In Win32 Application Wizard click Next.

Step 8: Now choose “Console Application” and check the option “Empty Project” and then click Finish.

Fundamental of ICT Page 6


After successful creation of project you will see a window like this.

Fundamental of ICT Page 7


Step 9: In the leftmost column (Solution Explorer) right click “Source Files”, select “Add” and then select
“New Item”.

Fundamental of ICT Page 8


Step 10: In the Add New Item dialog box choose “C++ file (.cpp)”, write the file name and click “Add”.

Fundamental of ICT Page 9


Step 11: In Solution Explorer double click on test.cpp.

Step 11: In the editor window write the following code;

#include <stdio.h>

int main()
{
//Output on the screen
printf( "I am alive! Beware.\n" );
getchar();
return 0;
}

Fundamental of ICT Page 10


Step 12: To compile your code select “Compile” from “Build” menu.

Fundamental of ICT Page 11


Step 13: After writing the code click on “Start Debugging” in “Debug” menu.

Fundamental of ICT Page 12


If there are no errors you will see your output in the following screen.

Fundamental of ICT Page 13


In case of errors they will be shown in “Output” window in the bottom.

Similarly in case you want to take an input from the user, use the following statement

#include<stdio.h>
#include<conio.h>

int main()
{
int myvariable;
printf("Enter a number:");
scanf("%d",&myvariable);
printf("%d",myvariable);

getchar();
return 0;
}

The output will look like this

Fundamental of ICT Page 14


Lab Task:

Q. No 1 Write a program which asks user to enter two numbers. The program then performs
mathematical operations of addition, subtraction, multiplication and division. Finally the
program displays the result on the screen.

Q. No 2 Write a program to convert a Fahrenheit value into Celsius., by taking input from the
user.

Hint:
F=9/5(c) +32

Q. No 3 Write a program that asks the user about a number and then displays its table as output
on the console.

Fundamental of ICT Page 15

You might also like