Page 245 - Computer_Science_F5
P. 245
Computer Science the market, commercial software are normally checked to examine the process of
bugs during the debugging process. Program Example 4.7 shows the C++ program
to illustrate the run-time error
Program Example 4.7:
FOR ONLINE READING ONLY
Run-time error
#include <iostream>
using namespace std;
int main()
{
int x = 10;
int div = x/0;
// wrong logic number is divided by 0,
// so this program abnormally terminates div = x/0;
cout << “result = “<< div;
return o;
}
Note:
Run-time errors are hard to trace because the compiler does not point to the line
at which the error occurs.
### Error
In the given example, there is Division by zero error. This is an example of run-
time error i.e. errors occurring while running the program.
Exercise 4.6
1. Study the following C++ program:
include<iostream>;
using namespace std;
int main
{
cout<<Read and enjoy C++ programming<<endl;
return 0;
}
236
for Advanced Secondary Schools
Computer Science Form 5.indd 236 23/07/2024 12:33

