हिंदी

Observe the following code. It may contain Syntax, Logical or runtime errors. int fnTotalDigits(int n) { int td=0; while(n>0) { n=n/10; td++; } return td; System.out.print("total digits=" + td);}

Advertisements
Advertisements

प्रश्न

Observe the following code. It may contain Syntax, Logical or runtime errors. Execute it in Java and identify the error, if any. Rewrite the code without the error. Also write the aim of the code.

int fnTotalDigits(int n)
{
    int td=0;
    while(n>0)
    {
        n=n/10;
        td++;
    }
    return td;
    System.out.print("total digits=" + td);
}
कोड लेखन
Advertisements

उत्तर

int fnTotalDigits(int n)
{
    int td=0;
    while(n>0)
    {
        n=n/10;
        td++;
    }
    System.out.print("total digits=" + td);
    return td;
}
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 3: User-Defined Methods - Exercises [पृष्ठ ९३]

APPEARS IN

रुपा पंडित Computer Applications [English] Class 10 ICSE
अध्याय 3 User-Defined Methods
Exercises | Q 7. (vii) | पृष्ठ ९३
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×