Question

use c++ language, keep it simple i am using code block

Exercise #2: Digitise a number Write the function digitiselint, int[]) of type int, which takes an integer N and finds all th

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int digitise(int, int[]);

int main() {
    int n, arr[100];
    cout << "Enter an integer: ";
    cin >> n;
    int count = digitise(n, arr);
    cout << "The digits of " << n << " are:";
    for (int i = 0; i < count; ++i) {
        cout << " " << arr[i];
    }
    cout << endl;
    return 0;
}

int digitise(int N, int digits[]) {
    int count = 0;
    while (N > 0) {
        digits[count++] = N % 10;
        N /= 10;
    }
    return count;
}

Enter an integer: 2309456 The digits of 2309456 are: 6 5 4 9 3 2

Add a comment
Know the answer?
Add Answer to:
use c++ language, keep it simple i am using code block Exercise #2: Digitise a number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • use c++ language, keep it simple i am using code block Exercise#2: Arrays with Random Numbers...

    use c++ language, keep it simple i am using code block Exercise#2: Arrays with Random Numbers Write a program that generates n random numbers as follows: Asks the user to input a positive integer n Asks the user to input the maximum value (say m) for the integers to be generated. Write a program that generates the n numbers in the range 0 to m. The program stores the generated numbers in an array A[ Asks the user to enter...

  • Using C++ Question#1: isPalíndrome Write the following function: bool isPalindrome(int) takes an integer and returns true...

    Using C++ Question#1: isPalíndrome Write the following function: bool isPalindrome(int) takes an integer and returns true if that integer is palindrome, otherwise it returns false. The function also prints the digits of the integer in reverse order in which they were found. Write a main) function that reads an integer, calls the function is whether the integer is a palindrome or not. Palindrome), and prints Sample input/output: nter an integer: 23434 nter an integer 23432 3434 is not a palindrome...

  • Write a program to reverse an integer number by using a function called reverse. The program...

    Write a program to reverse an integer number by using a function called reverse. The program reads in an integer number and prints its reverse order. Note that the function receives the number via a pointer, and uses the pointer to write the reverse number on the main function. The function MUST be used AS IS: void reverse(int *n) Language in C Bonus Problem: Number Reverser reverse c Write a program to reverse an integer number by using a function...

  • help me solving this both please in c++ language 6 Write function max(int al Lint n)...

    help me solving this both please in c++ language 6 Write function max(int al Lint n) that receives an array of integer and its length, it returns the maximum number in that array. Test your function in main. 7) Write functin reverse (char x[ .int n) that reieves an array of characters and reverse the order of its elements. Test this function in main.

  • Consider the following program that reads a number of nonnegative integers into an array and prints...

    Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array.   Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Add the following to the program: Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the...

  • if it is possible help me with the code in C language and I could learn...

    if it is possible help me with the code in C language and I could learn it, thanks ! Write a function that computes the integer mean of an array of integers. For example, the integer mean of -1, 4, 2 is (-1 + 4 + 2)/3 = 5/3 = 1, where/des integer division. The function should implement the following specification:/* Computes the integer mean of an array and stores it * where mn references. Returns -1 for erroneous input...

  • In C language Write a program that includes a function search() that finds the index of...

    In C language Write a program that includes a function search() that finds the index of the first element of an input array that contains the value specified. n is the size of the array. If no element of the array contains the value, then the function should return -1. The program takes an int array, the number of elements in the array, and the value that it searches for. The main function takes input, calls the search()function, and displays...

  • Use C++ language, keep it simple Exercise #2: Strings' operations Write a C++ program that prompts...

    Use C++ language, keep it simple Exercise #2: Strings' operations Write a C++ program that prompts the user to enter a sentence, the program then does the following: 1. Prints the total characters in the sentence. 2. Prints the word count of the sentence, assuming only one space between each tow words. 3. Prints total vowel (a, e, i, o, u) in the sentence. 4. Prints the vowel frequency as shown in the sample below. 5. Prints the sentence in...

  • Language C Code Write a program that takes two integer arrays (A and B) and sums...

    Language C Code Write a program that takes two integer arrays (A and B) and sums them together (element wise). A third array to accept the result should be passed in as the output argument. Assume the arrays are all the same size. The argument N is the size of the arrays. Your code should provide a function with the following signature: void array Addition (int A[], int B[], int N, int output[]) { } Your code must also provide...

  • PLEASE HELP!!! C PROGRAMMING CODE!!! Please solve these functions using the prototypes provided. At the end...

    PLEASE HELP!!! C PROGRAMMING CODE!!! Please solve these functions using the prototypes provided. At the end please include a main function that tests the functions that will go into a separate driver file. Prototypes int R_get_int (void); int R_pow void R Jarvis int start); void R_fill_array(int arrayll, int len); void R_prt_array (int arrayl, int len) void R-copy-back (int from[], int to [], int len); int R_count_num (int num, int arrayll, int len) (int base, int ex) 3. Build and run...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT