मराठी

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

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 1: Revision of Class 9 Syllabus - Exercises [पृष्ठ ४६]

APPEARS IN

रूपा पंडित Computer Applications [English] Class 10 ICSE
पाठ 1 Revision of Class 9 Syllabus
Exercises | Q 6. (i) | पृष्ठ ४६
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×