मराठी

What will be the output of the given Java code after the calculation [note the data types]? int m = 62, k = 10,r = 0, q = 0; r = m/k; q = k/m; System.out.println ("R=" +r+ “Q=" +q);

Advertisements
Advertisements

प्रश्न

What will be the output of the given Java code after the calculation [note the data types]?

int m = 62, k = 10,r = 0, q = 0; 

r = m/k;

q = k/m;

System.out.println ("R=" +r+ “Q=" +q);

बेरीज
Advertisements

उत्तर

r = m/k;

  • This is integer division because both variables are int `62/10` = 6.2.
  • r gets the value 6.

q = k/m;

  • This evaluates `10/62` = 0.1612..
  • Java truncates the decimal portion completely, leaving 0.
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 5. (i) | पृष्ठ ४५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×