हिंदी

Given below is the program with errors in it. Identify the errors. Rewrite the program and predict the output. import java.util.* class Program { int A, B, C; Scanner sc = new Scanner.System.in;

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 Program
{
       int A, B, C;
       Scanner sc = new Scanner.System.in;
       System.out.print("\n Enter the value of A: ");
       A = sc.nextInt();
       If (A % 10=0 )
       {
           System.out.println(" A is an Even number ");
           else
           {
              System.out.println(" A is an Odd number ");
           }
       }
}
कोड लेखन
Advertisements

उत्तर

import java.util.*;
class Program
{
    void main()
    {
        int A, B, С;
        Scanner sc=new Scanner(System.in);
        System.out.print("\n Enter the value of A:");
        A = sc.nextInt();
        if (A % 2=0)
        {
           System.out.println(" A is an Even number");
        }
        else
        {
           System.out.println(" A is an Odd number");
    }
}
}

To test if a number is even or odd.

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. (ii) | पृष्ठ ४७
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×