HOW MANY DIGITS DO I HAVE CodeChef Solution

Problem – HOW MANY DIGITS DO I HAVE CodeChef Solution

Write a program to obtain a number (N) from the user and display whether the number is a one digit number, 2 digit number, 3 digit number or more than 3 digit number

###Input:

  • First line will contain the number NN,

###Output: Print “1” if N is a 1 digit number.

Print “2” if N is a 2 digit number.

Print “3” if N is a 3 digit number.

Print “More than 3 digits” if N has more than 3 digits.

###Constraints

  • 0≤N≤1000000

###Sample Input: 9

###Sample Output: 1

HOW MANY DIGITS DO I HAVE CodeChef Solution in Java

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
Scanner sc = new Scanner(System.in);
String n = sc.next();
if(n.length() == 1)
System.out.println("1");
	else if(n.length() == 2)
	System.out.println("2");
else if(n.length() == 3)
	 System.out.println("3");
	 else 
System.out.println("More than 3 digits");
	}
}




HOW MANY DIGITS DO I HAVE CodeChef Solution in Pyth 3

n=int(input())
n=str(n)
if len(n)<3:
    print(len(n))
elif len(n)==3:
    print(len(n))
else:
    print('More than 3 digits')

HOW MANY DIGITS DO I HAVE CodeChef Solution in C++14

#include <bits/stdc++.h>
using namespace std;

int main() {
         
            int n,count=0; cin>>n;
            while(n>0){
                n/=10;
                count++;
            }
            if(count<=3){
                cout<<count<<endl;
            }
            else{
                cout<<"More than 3 digits"<<endl;
            }
          
	return 0;
}
HOW MANY DIGITS DO I HAVE CodeChef Solution Review:

In our experience, we suggest you solve this HOW MANY DIGITS DO I HAVE CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the HOW MANY DIGITS DO I HAVE CodeChef Solution

Find on CodeChef

Conclusion:

I hope this HOW MANY DIGITS DO I HAVE CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *