Sie sind auf Seite 1von 8

CS-113 Introduction to Programming

Department of Computing
Lab 1: Introduction to Programming
CS-113: Introduction to Programming
10
th
September 2014
Class: BEE-6AB
Fall 2014
Instructor: Miss Samin Khaliq

CS-113 Introduction to Programming Page 2

Lab 1: Introduction to Programming

Introduction
This lab is about familiarization with IDE of Visual Studio and writing simple programs using C
language.
Objective
At the end of this lab student will be able to learn how to write their first C Project in Microsoft
Visual Studio 2012 Integrated Development Environment (IDE).
Description
1. Launch Microsoft Visual Studio by clicking Start All Programs Microsoft Visual
Studio 2012 Microsoft Visual Studio 2012.
2. Click on File New Project in the menu bar.










CS-113 Introduction to Programming
Page 3

3. Choose Visual C++ Select Empty Project. Type HelloWorldProject as the Name of the
project.



4. Right click on the Source Files folder in the Solution Explorer window. Choose Add New
Item .







CS-113 Introduction to Programming
Page 4

5. Click on C++ file (.cpp) and call it Task1. Then click on Add.














CS-113 Introduction to Programming
Page 5

6. Now you are ready to type in the C Program given below in the Code Editor window.






7. Click on Debug from the menu bar, click on Start without Debugging to execute your
program or you can also press Ctrl+F5.









CS-113 Introduction to Programming
Page 6

8. The output of the program should be visible in the command prompt console. (Note: If
you see a warning window, check "Do not show this dialog again" checkbox and click
Yes.




9. To close the command prompt window, press any key on the keyboard.


Congratulations you have created your first C Project.

Instructions
Having read the Intro to Visual C++ document, you should now be able to use an IDE
(Integrated Development Environment) to write, compile and execute a C program. Using Visual
C++ IDE, complete the tasks below and save them on the computer. Insert the solution/answer in
this document as directed below. You must show the execution of below tasks, along with your
completed Word document to get your work graded. You must also submit this Word document
on the LMS.
Deliverables
Compile a single Word document by filling in the solution/answer part and submit this Word file
on LMS.
This lab is graded. Min marks: 0. Max marks: 10.



CS-113 Introduction to Programming
Page 7


Lab Tasks
Q1) Create and execute Kernighan and Ritchies famous hello, world program:
#include <stdio.h>
#include <conio.h>
int main(void)
{
printf( your name \n);
getch();
}
(i) Make changes to the program such that your first name and last name are printed on two
separate lines.

Answer:
Solution


Output


Q2) Consider the following program:
#include <stdio.h>
#include <conio.h>
int main(void)
{
printf("Any intelligent fool,");
printf( "\ncan make things bigger, more complex, \nand more violent.");
printf("It takes a touch of genius -- \nand a lot of courage -- ");
printf("to move in the opposite direction.");
printf("--Albert Einstein");
getch();
return 0;
}

(i) Make changes to the program such all the text is printed without any new line breaks.
(iii) Show quotation marks on Albert Einstein on the output screen, like Albert Einstein by
using the command \ Albert Einstein \and paste your code below.



CS-113 Introduction to Programming
Page 8


Answer:
Solution


Output



Q3) Given the following program:
#include <stdio.h>
#include <conio.h>
int main(void)
{
// your code here
printf( \n);
getch();
return 0;
}
(i) write a program to display the following by changing indentation and line breaks:

---------- Engineering is Fun--------
Fun is life.
Life is precious.
------------------------------------------

(ii) Add comments in this program clearly identifying start of program, end of program and
monitor display statement. Comments are written on each line with the symbol // e.g.
// This is a comment.

Answer:
Solution


Output

Das könnte Ihnen auch gefallen