Practice6 - Reminder #include...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Reminder #include <stdio.h> void swap( int tens, int units) { int tmp; tmp=units; units=tens; tens=tmp; } int main() { int input,output; int tens,units; printf("Please enter a two digit integer\n"); scanf("%d",&input); units=input%10; tens=input/10; swap(tens,units); output=tens*10+units; printf("The reverse number is %d\n",output); return 0; } The debugger Some programs may compile correctly, yet not produce the desirable results. These programs are valid and correct C programs, yet not the programs we meant to write! The debugger can be used to follow the program step by step and may help detecting bugs in an already compiled program. The debuggers common features Setting breakpoints (a point where the execution stops): bring the cursor to desired line and press the palm icon or F9. A dark red dot appears near the line. Executing a debugged run: Build->start debug->go or F5. The program will run and stop at the first breakpoint. The debuggers common features (cont.) Stopping at a specific line: Bringing the cursor to the line and press ctrl+F10, or Build->start debug->go to cursor. The program will stop at that point. Stepping to the next line F10. Entering a function F11. Seeing variable values quickwatch and/or debug window at the bottom. The yellow arrow indicates our whereabouts at any given moment. Example #include <stdio.h> void swap( int tens, int units) { int tmp; tmp=units; units=tens; tens=tmp; } int main() { int input,output; int tens,units; printf("Please enter a two digit integer\n"); scanf("%d",&input); units=input%10; tens=input/10; swap(tens,units); output=tens*10+units; printf("The reverse number is %d\n",output); return 0; } Arrays A block of many variables of the same type Array can be declared for any type E.g. int A[10] is an array of 10 integers. Examples: list of students marks series of numbers entered by user vectors matrices Arrays in Memory Sequence of variables of specified type The array variable itself holds the address in memory of beginning of sequence Example: double S[10]; The k-th element of array A is specified by A[k-1] (0 based) 1 2 3 4 5 6 7 8 9 S...
View Full Document

Page1 / 47

Practice6 - Reminder #include...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online