You are on page 1of 9

www.VUSR.

net

Visual Programming (CS410)


Assignment # 2
Total marks = 20
Deadline Date = 06-11-2009

Please carefully read the following instructions before attempting the


assignment.

Rules for Marking


It should be clear that your assignment would not get any credit if:

§ The assignment is submitted after due date.


§ The submitted assignment does not open or file corrupt.
§ The assignment is copied. Note that strict action would be taken if the
submitted assignment is copied from any other student. Both students will be
punished severely. SR
1) You should concern recommended books to clarify your concepts as handouts are not
sufficient.
2) You are supposed to submit your assignment in MS Word format and any other
formats like scan images, PDF, Zip, rar, docx, .CPP etc will not be accepted
3) You are advised to upload your assignment at least two days before Due date.
U
Important Note: Assignment comprises of Two questions. Note that no
assignment will be accepted after due date via email in any case (whether it is the
V

case of load shedding or emergency electric failure or internet malfunctioning etc.).


Hence, refrain from uploading assignment in the last hour of the deadline, and try
to upload Solution at least 02 (two) days before the assignment to avoid
inconvenience later on.

For any query please contact: CS410@vu.edu.pk

http://lms.vusr.net All VU Past Study Resource


www.VUSR.net

Question – 1 [Marks 10]

Q1. Describe the following in two-three lines [2 Marks Per question]:

1.1) #define MAX(a,b) (((a) > (b)) ? (a) : (b))

1.2) #define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))

1.3) typedef void* HANDLE

1.4) WinMain(…) function

1.5) GetCommandLine() function

Question – 2 [Marks 10]

Develop a Win32 Program with the name “Add” that takes a string as input at
command line. The command line argument should be of the following format
(commandline argument may be provided from DOS console):
SR
D:\Add\Debug>Add 2,4

The program will extract the integer values from commandline string (e.g. it will extract
the values “2” and “4” in above argument) and will add them, finally the result will be
displayed in a message box:
U
V

http://lms.vusr.net All VU Past Study Resource


www.VUSR.net

Start your project in the following way:

1) Open Visual C++6.0

SR
U
V

http://lms.vusr.net All VU Past Study Resource


www.VUSR.net

2) Click File > New menu. “New” dialog box will appear.

SR
U
V

http://lms.vusr.net All VU Past Study Resource


www.VUSR.net

3) Select “Win32 Application” from “Projects” Tab and enter Project Name. Finally
click “Ok” button

SR
U
V

http://lms.vusr.net All VU Past Study Resource


www.VUSR.net

4) Following dialog box will appear

SR
U
V

http://lms.vusr.net All VU Past Study Resource


www.VUSR.net

5) Select “A Simple Win32 application” and click finish button

SR
U
V

http://lms.vusr.net All VU Past Study Resource


www.VUSR.net

6) From “New Project Information” dialog, click “OK” button

SR
U
V

http://lms.vusr.net All VU Past Study Resource


www.VUSR.net

7) In “Workspace” window, open “Class View” and double click “WinMain”


function and write down your code in “WinMain”

SR
Tips:

You can use:


U
1) GetCommandline() function to get the string passed to program from command
line.
V

2) “strtok” function (or your own logic) to tokenize the string and extract the
integer values from string passed as commandline.

3) MessageBox(…) function to display the result of addition.

NOTE:

Don’t send “.CPP” file, instead submit solution of both questions in a single “.DOC”
file. Use VC++6.0 for developing code and not any other compiler.

http://lms.vusr.net All VU Past Study Resource

You might also like