Wipro
Company
Logical Reasoning
Mathematical Reasoning
select a number between 1 to 99999999. write a program in java so that you can receive a number and calculate its frequency in that given number.
(Eg: 2 in 12521222 ans: 5)
Read Solution (Total 3)
-
- import java.util.*;
class test12
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int number,k,count=0,result=0;
System.out.println("Enter no between 1 to 99999999999");
number=sc.nextInt();
System.out.println("Enter no to be checked");
k=sc.nextInt();
while(number>0)
{
result=number%10;
number=number/10;
if(result==k)
count++;
}
System.out.println(count);
}
} - 6 years agoHelpfull: Yes(3) No(0)
- #include
main(){
int i,j,k,n,c=0;
printf("Enter any number blw 1 and 99999999n");
scanf("%d",&n);
printf("Enter the number to find the frequencyn");
scanf("%d",&k);
for(i=0;i - 9 years agoHelpfull: Yes(1) No(5)
- import java.util.Scanner;
public class NumberFrequency
{
public static void main(String[] args)
{
Scanner ac = new Scanner(System.in);
System.out.println("Enter No. 1 to 99999999 :- ");
long value = ac.nextLong();
long number = value;
System.out.println("Enter No. ye want check Frequency:- ");
int no = ac.nextInt();
int check = 0;
int digit = 0;
for (int i=0; i8)
{
System.err.println("Exceed Digit Limit......");
System.exit(0);
}
int[] range = new int[digit];
number = value;
for (int i=(digit-1); i>=0 ; i--)
{
range[i] = (int) (number%10) ;
number = number/10 ;
}
for (int j=0; j - 6 years agoHelpfull: Yes(0) No(0)
Wipro Other Question