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 [पृष्ठ ४७]
