Exercise: Types of Errors in C++
Exercise: Types of Errors in C++
Exercise: Types of Errors in C++
Logical error:- This error won’t be displayed on the screen. However it will lead to display wrong results. Example: An infinite loop. This error lead to abnormal termination of a
program or infinite loop.
Runtime error:- This error occurs while running a program by displaying the message listed below.
I. Division by 0.
II. Overflow
III. Underflow
Answer:-
#include<iostream>
void main()
{
int a,b;
cin>>a;
b=a;
cout <<"b="<<a;
}
Exercise
Q. Find the errors in following programs.
1. #include “iostream”
void main()
{
const PI=3.14;
int r,h;
cout>>”Enter values of r and h’
cin>>r,h;
v=PI*r*r*h;
cout<<’volume=”<<v;
}
2. #include<iostream>
#define p=10000
int main()
{
int r,t
cout<<”Enter r,t;
cin>>r>>t;
float si= p*r*t/100.0;
cout>>”Simple interest =”<<SI;
getch()
}
Posted by Dipesh Palod at 13:58
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest