0% found this document useful (0 votes)
35 views10 pages

Lecture#10

Uploaded by

Rashad Mahmood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views10 pages

Lecture#10

Uploaded by

Rashad Mahmood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

COMPUTER SCIENCE

12
SUBJECT TEACHER:
RASHAD MAHMOOD
CMA (Managerial) MBA-IT & Business
Cisco Certified Network Administrator
Microsoft Certified System Engineer
Linux Operating System Certified
Comptia Computer Hardware Certified

CHAPTER 8: Getting Started with C

Copyright @ Superior College Kharian RASHAD MAHMOOD ( IT SPECIALIZED)


Topics

• Program and Programming languages


• Characteristics of High-Level Programming Languages
• Differentiate between Low-Level and High-Level Languages
• Source Code and Object Code
• Language Processors or Translators
• History of C Language
• Advantages or Characteristics of C Language
• Turbo C++
• Create, Edit , Compile and Execute C Program
• Steps to prepare C Program for Execution

Copyright @ Superior College Kharian RASHAD MAHMOOD ( IT SPECIALIZED)


Topics(Cont.)
• .c and .cpp Extensions
• Process of setting te output and source directories
• Basic Structure of C Program
• Preprocessor Directives
• Header Files
• main Function
• C Statements
• Bug and Debug
• Types of Error ( Syntax errors, Logical Errors and Run-Time Errors
• Unstructured and Structured Programming Languages
• Debugging Features of Turbo C++

Copyright @ Superior College Kharian RASHAD MAHMOOD ( IT SPECIALIZED)


Q13 (Long) Define Bug and Debugging
 Bug
• An error in a computer program
• Programmer can make different errors while writing programs
• A program cannot be compiled if it contains any syntax error
• The compiler detects and displays error message to describe the cause of error

 Debugging
• Process of finding and removing
• The errors msut be removed from the program before it can be
compiled and executed

Copyright @ Superior College Kharian RASHAD MAHMOOD ( IT SPECIALIZED)


Q14 (Long) While writing a C program how many types of errors can occur??

 Syntax Errors
• A type of error that occurs when an invalid statement is written in the program
• Compiler detects syntax errors
• A program containing syntax errors cannot be compiled successfully
Syntax is a collection of
 Causes of Syntax Erros rules for writing programs
• The statement terminator is missing at the end of statement in any language
• A misspelled keyword is used in the program
• Any of the delimiters is missing
Example
Typing forr instead of for is an example
 Logical Errors
• A type of error that occurs due to poor logic of the programmer
• A statement with logical error may produce unexpected and wrong results in program
• Difficult to find because translator cannot detect
• It can only be detected by examining the program thoroughly
Example
• Using wrong conditions in program such as writing a<5 instead of a>5
• Using wrong formula as writing average=total *5 instead of average=total/5
Copyright @ Superior College Kharian RASHAD MAHMOOD ( IT SPECIALIZED)
 Run Time Errors
• A type of error that occurs during the execution of program
• It occurs when a statement directs the computer to execute an illegal operation
• These are detected and displayed by the computer during execution
• Normally occur due to wrong input from the user
• Computer stops executing the program and displays error message if a run time error occurs
Example
• Dividing a number by zero
• User may enter wrong type of data
• User may ask the program to open a file does not exist

Copyright @ Superior College Kharian RASHAD MAHMOOD ( IT SPECIALIZED)


It cannot be detected by the compiler

It does not crash the program

The user needs to review the whole program to find out logical error

It may take a lot of time for detecting logical error

Copyright @ Superior College Kharian RASHAD MAHMOOD ( IT SPECIALIZED)


Q15 (Long) Discuss some debugging features of
Turbo C++?
• Debugger provides the facility to find errors by executing one line of program at one time
Single • Enables the programmer to detect the exact place of error
Stepping • Procedure to execute one step at a time with single stepping
• Select Run > Trace Into OR press F7

• Used to check the value of variable as the program executes


• Indicates how the values of variables change during program execution
• Normally used with single stepping
• Place the cursor on the variable whose value is to be checked.
• Select Debug > Watches. A submenu will appear.
Watches • Select Add Watch from the submenu.
• The selected variable will appear in Watch expression field.
• Click OK OR press Enter.
• A new window will appear indicating that the selected symbol is undefined.
• Select Run > Trace Into OR press F7 to execute single stepping.
• The value of the selected variable will appear in Watch window.

Copyright @ Superior College Kharian RASHAD MAHMOOD ( IT SPECIALIZED)


• Used to mark a part of program where program execution will stop
• Program executes all statements up to the breakpoint and then stops
• User can check the values of variable at this point by using Watch window by single
Breakpoints stepping the remaining part of the program
• Place the cursor on the line on which the breakpoint is to be inserted.
• Select Debug > Toggle breakpoint OR press CTRL+F8.
• The breakpoint will be inserted and the line will be highlighted.

• Used to change the value of variable during program execution


• Can be useful if the user is single stepping the program and wants to change the
value of certain variable
Evaluate/Modify • Select Debug > Evaluate/Modify.
Window • A new window will appear with three fields.
• Enter the name of the variable whose value is to be modified in Expression field.
• Enter the new value for the variable in New Value field.
• The value of the third field Result will also change automatically.

Copyright @ Superior College Kharian RASHAD MAHMOOD ( IT SPECIALIZED)


Copyright @ Superior College Kharian RASHAD MAHMOOD ( IT SPECIALIZED)

You might also like