1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
pogonyaev
3 years ago
10

A method countDigits(int num) of class Digits returns the remainder when the input argument num(num > 0) is divided by the nu

mber of digits in num. The function compiles successfully but fails to return the desired result due to logical errors. Your task is to debug the program to pass all the test cases.
Computers and Technology
1 answer:
sertanlavr [38]3 years ago
7 0

Answer:

#include <iostream>

using namespace std;

class Digits

{

   public:

   int num;

   int read()       //method to read num from user

   {

       cout<<"Enter number(>0)\n";

       cin>>num;

       return num;

   }

   int digit_count(int num)  //method to count number of digits of num

   {

       int count=0;

       while(num>0)    //loop till num>0

       {

           num/=10;

           count++;   //counter which counts number of digits

       }

       return count;

   }

   int countDigits(int num)   //method to return remainder

   {

       int c=digit_count(num); //calls method inside method

       return num%c;  

   }

};

int main()

{

   Digits d;    //object of class Digits is created

   int number=d.read();   //num is read from user

   cout<<"\nRemainder is : "<<d.countDigits(number);  //used to find remainder

   return 0;

}

Output :

Enter number(>0)

343

Remainder is : 1

Explanation:

As program is missing to find errors , a logically write program is written to find the remainder when a number is divided by its number of digits. A class  Digits is constructed which has public variable num and methods read(), digit_count(), countDigits().

  • read() - This method reads value of num from the user and return num.
  • digit_count() - This method takes a integer as parameter and counts the number of digits of a number passed as argument. while loop is used to increement the counter until num<0. This returns the value of count.
  • countDigits() - This method takes a integer as a parameter and returns remainder when the argument is divided by number of  digits of argument. Number of digits is calculated by using method digit_count().

At last in main method , object of Digits class is created and its methods are used to find the output.

You might be interested in
Which of the following commands would I use to begin a new presentation?
ki77a [65]

Answer:

begin >new

Explanation:

just trust me ok hehe

7 0
3 years ago
Noticing his reduced performance at work, Dan enrolled himself for training sessions offered by the company and saw his producti
Luden [163]

A. self-efficacy.

B. overreward inequity.

C. expectancy.

D. cognitive distortion.

Answer:B. overreward inequity.

Explanation: Overreward inequity is a term mostly associated with the feeling of guilt by an employee who believes that his contributions to work or his performance rating is less than what he or she is been paid for.

An employee with this kind of guilt feelings will mostly like do his or her best to engage in in performance improvement Activities which includes enrollment for training and classes to enhance his or her performance.

6 0
2 years ago
What are the three primary separation of concerns on the client-side of a dynamic web application? (Check all that apply)
nlexa [21]

Answer:

Behaviour

Style

Structure

Explanation:

Above are the three primary separation of concerns for a web application at client side.

Structure --> we can define the structure of the application at client side using HTML

style-->style is used to give some styling information like font,color,headings so on at client side .In general we use CSS to do this at client side

Behaviour--> it actually defines the functionality of the elements at client side like when we click button what it should do.We will use JavaScript to define the behaviours at client side

7 0
3 years ago
How would you create a tint of a color?
svetlana [45]
D. white with a hue
HOPE THIS HELPS
5 0
2 years ago
Taylor volunteered as a computer support specialist for his university's online library. Which part of his resume should include
Sophie [7]
 it would be experience 
<span />
8 0
3 years ago
Read 2 more answers
Other questions:
  • If you are making a 30-minute presentation, how much time should be spent summarizing your points and making any closing remarks
    11·2 answers
  • If a gas gosts 3.60 per gallon how much doe sit cost to drive 500 miles in the city
    5·1 answer
  • You want to discard your old computer and want to securely erase the data from your hard drive. What can you use to do this and
    6·1 answer
  • __________ involves determining what qualities are to beused to perform project activities.
    9·1 answer
  • Write a code to define a structure named student, which includes name, student number and email address
    5·1 answer
  • when files on storage are scattered throughout different disks or different parts of a disk, what is it called
    10·1 answer
  • g Write a function named vowels that has one parameter and will return two values. Here is how the function works: Use a while l
    9·1 answer
  • What are the two types of electronic components
    15·2 answers
  • To speed up data retrieval, more vehicles will be upgraded to cellular connections and be able to transmit data to the ETL proce
    9·1 answer
  • Scenario: The deputy incident commander will be replacing the current incident commander, who needs to attend to a family emerge
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!