-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC79ErrorsDemo.java
More file actions
26 lines (21 loc) · 814 Bytes
/
Copy pathC79ErrorsDemo.java
File metadata and controls
26 lines (21 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Scanner;
public class C79ErrorsDemo {
public static void main(String[] args) {
// Logical error demo
// write a program to print numbers between 1 to 10
System.out.println(2);
for (double i = 1; i < 10; i++) {
System.out.println(2 * i + 1);
// this will also print 9 which is not a prime number that why this is logical
// error
}
//Runtime error is also a exception
//
int k ;
Scanner sc=new Scanner(System.in);
k=sc.nextInt();
System.out.println("Interger past of 1000 divided by k is "+1000/k);
//If user input 0 then it through an exception because it is not define in java
//this is a exapmle of run time error
}
}