Advertisements
Advertisements
प्रश्न
Given below is the program with errors in it. Identify the errors. Rewrite the program and predict the output.
import java.util.*
class Prog 1
{
void main
{
int A, B, С;
Scanner sc=new Scanner(System.in ());
System.out.print("\n Enter the value of A : ");
A = sc.nextInt();
System.out.print("\n Enter the value of B: ");
B = sc.nextInt();
If (A<B)
{
C=A;
}
else
{
C=B;
}
else
{
C=C;
}
System.out.print("\n The largest is="+C);
}
}कोड लेखन
Advertisements
उत्तर
import java.util.*;
class Prog1
{
void main()
{
int A, B, C;
Scanner sc=new Scanner(System.in);
System.out.print("\n Enter the value of A: ");
A = sc.nextInt();
System.out.print("\n Enter the value of B: ");
B = sc.nextInt();
if (A>B)
{
C=A;
}
else
{
C=B;
}
System.out.print("\n The largest is="+C);
}
}
To find the largest of A, B
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
