Computer Science, asked by nityaagarwal2007, 1 month ago

still there is showing 6 errors why can anyone tell me​

Attachments:

Answers

Answered by kamalrajatjoshi94
1

Answer:

The given program is in Java:-

import java.io.*;

class Add

{

public static void main(String args[ ])throws IOException

{

InputStreamReader read=new InputStreamReader(System.in);

BufferedReader in=new BufferedReader(read);

System.out.println("Enter the value of a and b");

a=Integer.parseInt(in.readLine());

b=Integer.parseInt(in.readLine());

System.out.println("The sum of two nos="+(a+b));

System.out.println("The diff of two nos="+(a-b));

}

}

Error:-

  • You have not declared variable a and b.

You must write int a,b; first.

Corrected program with output attached:-

import java.io.*;

class Add

{

public static void main(String args[ ])throws IOException

{

InputStreamReader read=new InputStreamReader(System.in);

BufferedReader in=new BufferedReader(read);

int a,b;

System.out.println("Enter the value of a and b");

a=Integer.parseInt(in.readLine());

b=Integer.parseInt(in.readLine());

System.out.println("The sum of two nos="+(a+b));

System.out.println("The diff of two nos="+(a-b));

}

}

  • The first photo is there is no error in the program now
  • The second photo is the output.
Attachments:
Similar questions