+ All Categories
Home > Documents > Guidelines for working with Microsoft Visual Studio 6.

Guidelines for working with Microsoft Visual Studio 6.

Date post: 21-Dec-2015
Category:
View: 224 times
Download: 0 times
Share this document with a friend
Popular Tags:
26
Guidelines for working with Microsoft Visual Studio 6
Transcript

Guidelines for working with Microsoft Visual Studio 6

Create a new Project

Select Project Type

Select Project Type

Create New File

Write the Code

Stage 2: Compile

Create Executable File

Stage 3: Execute

Execution Window

Inserting a breakpoint

Press right mouse button and select “Insert Breakpoint”

Start Debugging

Stopping at a Breakpoint

The “Watch” window will show the values of the variables

Stepping Over

“Step over” and check the values in the “Watch” window

Run to Cursor

“Run to cursor” will run till the current cursor position

Checking a value of a variable

Checking a value of a variable

Choose “Add Watch” to a variable to the “Watch” window

Factorial

#include <stdio.h>

int main(void) {int i,n, fact=1;printf("Enter a number: ");scanf("%d", &n);

for (i =1; i<=n; i++){fact*=i;

}printf ("\nThe functorial is: %d\n", fact);return 0;

}

Stepping through a Loop

Errors

• Syntax errors – caught by compiler• Run-time errors - seen during program execution.• Reasons for run-time errors:

– Infinite loops – Division by zero – Many more …

• Important Termination Commands:– Unix: <Cntrl>-C – MS-DOS: <Cntrl>-C or <Cntrl>-break

Compilation Errors Example

Run Time Error Example

Don’t try this at home!!!

Infinite Loop

Don’t try this at home!!!

Use <Cntrl> C to terminate the execution

Code and Compilation Examples

Printing Numbers

#include <stdio.h>

int main(void) {

int i;

for(i=0; i<100; i++){

printf("%d\n", i);

}

return 0;

}

Printing Numbers#include <stdio.h>int main(void){

int i,j;for(i=0; i<20; i++){

for(j=0;j<20;j++){printf("%d ", i);

}printf("\n");

}return 0;

}


Recommended