diff --git a/Employeesdetails.c b/Employeesdetails.c new file mode 100644 index 0000000..5d588a1 --- /dev/null +++ b/Employeesdetails.c @@ -0,0 +1,28 @@ + +#include + + +struct employee{ + char name[30]; + int empId; + float salary; +}; + +int main() +{ + + struct employee emp; + + + printf("\nEnter details :\n"); + printf("Name ?:"); gets(emp.name); + printf("ID ?:"); scanf("%d",&emp.empId); + printf("Salary ?:"); scanf("%f",&emp.salary); + + + printf("\nEntered detail is:"); + printf("Name: %s" ,emp.name); + printf("Id: %d" ,emp.empId); + printf("Salary: %f\n",emp.salary); + return 0; +} diff --git a/Multipleblock.Java b/Multipleblock.Java new file mode 100644 index 0000000..5c00d98 --- /dev/null +++ b/Multipleblock.Java @@ -0,0 +1,37 @@ +import java.util.*; +public class MyClass { + public static void main(String[] args) + { + int a, b, div; + Scanner s = new Scanner(System.in); + + try + { + System.out.println("Enter 1st number: "); + a = s.nextInt(); + + System.out.println("Enter 2nd number: "); + b = s.nextInt(); + + div = a / b; + + System.out.println("The answer is: " + div); + } + + catch(ArithmeticException e) + { + System.out.println("Arithmetic Exception! You're dividing by zero."); + } + + catch(NumberFormatException e) + { + System.out.println("You entered a non-numerical value."); + } + + catch(Exception e) + + { + System.out.println(e); + } + } +} diff --git a/Multiplecatchblock.Java b/Multiplecatchblock.Java new file mode 100644 index 0000000..d36f016 --- /dev/null +++ b/Multiplecatchblock.Java @@ -0,0 +1,57 @@ +import java.util.*; + +public class MyClass { + + public static void main(String[] args) { + + int a, b, div; + + Scanner s = new Scanner(System.in); + + try + + { + + System.out.println("Enter 1st number: "); + + a = s.nextInt(); + + System.out.println("Enter 2nd number: "); + + b = s.nextInt(); + + div = a / b; + + System.out.println("The answer is: " + div); + + } + + catch(ArithmeticException e) + + { + + System.out.println("Arithmetic Exception! You're dividing by zero."); + + } + + catch(NumberFormatException e) + + { + + System.out.println("You entered a non-numerical value."); + + } + + catch(Exception e) + + + + { + + System.out.println(e); + + } + + } + +}