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.
Answer:
// function with memory leak
void func_to_show_mem_leak() {
int *pointer;
pointer = malloc(10 * sizeof(int));
*(pointer+3) = 99;}
// driver code
int main()
{
// Call the function
// to get the memory leak
func_to_show_mem_leak();
return 0; }
Explanation:
Memory leakage occurs when programmers allocates memory by using new keyword and forgets to deallocate the memory by using delete() function or delete[] operator. One of the most memory leakage occurs by using wrong delete operator.
The delete operator should be used to free a single allocated memory space, whereas the delete [] operator should be used to free an array of data values.
To see additional functions available in an open desktop, document or website, the action that the user should perform is; Right click the mouse
- When working on either open desktop, document or website, we make use of the mouse button to carry out a couple of operations.
- Now, the left mouse button is the main button of the mouse primarily used for selection of an item or word or object e.t.c. Whereas, when it comes to seeing more options or functions associated with the highlighted item of the mouse left button or just random additional functions without any selection, right clicking the mouse button would be the best action.
Read more on additional functions at; brainly.com/question/1092681
Answer:
In this situation OR operator are used
In this operator if one input is one then the out put will be one or if one condition is true and one is false the result is true.The out put is always one in this truth table except input output both are zero
Truth table of OR
A B C
0 0 0
0 1 1
1 0 1
1 1 1
Simple, really. No hacks required. Just study and you'll do fine.