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
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
