answersLogoWhite

0


Best Answer

== ==

// Returns number of 7s in num.

int numSevens(int num) {

int _num = num;

int numSevens = 0;

while( _num > 0 ) {

if( (_num % 10) == 7 ) {

++numSevens;

}

_num /= 10;

}

return numSevens;

}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a function that reads an integer and determines and prints how many digits in the integer are 7s?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a c plus plus program that inputs 5 integers from the user and separates the integer into individual digits and prints the digits separated from one another by three spaces each.?

// create an BufferedReader from the standard input stream BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String currentLine = ""; int total = 0; int[] ints = new int[5]; // read integers while (total < 5) { // get input System.out.print("Input an integer: "); currentLine = in.readLine(); // parse as integer try { int input = Integer.parseInt(currentLine); ints[total] = input; ++total; } catch (final NumberFormatException ex) { System.out.println("That was not an integer."); } } // print each number for (int i = 0; i < ints.length; ++i) { // get individual digits if (ints[i] == 0) { System.out.println(0); } else { while (ints[i] > 0) { System.out.println(ints[i] % 10); ints[i] /= 10; } } } Note that this prints out the digits in reverse order (2048 will print 8 first and 2 last).


Write a program that input a positive integer and prints a triangle using for loop?

write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?


Individual digits sum with flowchart and algorithm?

Well, it's very hard to write a flowchart in text, so I'll give you some pseudo code instead. int number = the given number int sum = 0 loop while number is not 0 sum = sum + (number mod 10) number = number / 10


Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


What is the solution of towers of hanoi problem?

This algorithm reads the value of number of discs and prints the move that are to be done for playing towers of hanoi.Pre: n is a positive integer which carries the value of number of discs.Post: prints the moves that are to be done for transferring discs in ascending order in another peg1.initialize value of n(positive integer greater than 1)2.moves = pow(2,disk)-13.if(n=1)i) moves disk from "from" to "to"4. end if5. elsei)hanoi(n-1,from,aux,to)ii) moves disc from "from" to "to''iii) hanoi(n-i,from,aux,to)6.end else7. prints the movesend towers_of_hanoi

Related questions

What determines correct tire pressure?

The manufacturer prints it on the sidewall for good reason.


What were the first known European block prints with a communication function?

Devotional prints of Saints.


Is the account number be printed in a receipt from an ATM?

The ATM usually prints just the last four digits of the account number. It fills in the other digits with X's


Write a c plus plus program that inputs 5 integers from the user and separates the integer into individual digits and prints the digits separated from one another by three spaces each.?

// create an BufferedReader from the standard input stream BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String currentLine = ""; int total = 0; int[] ints = new int[5]; // read integers while (total < 5) { // get input System.out.print("Input an integer: "); currentLine = in.readLine(); // parse as integer try { int input = Integer.parseInt(currentLine); ints[total] = input; ++total; } catch (final NumberFormatException ex) { System.out.println("That was not an integer."); } } // print each number for (int i = 0; i < ints.length; ++i) { // get individual digits if (ints[i] == 0) { System.out.println(0); } else { while (ints[i] > 0) { System.out.println(ints[i] % 10); ints[i] /= 10; } } } Note that this prints out the digits in reverse order (2048 will print 8 first and 2 last).


Why printf is used instead of print in c?

The printf() function prints a formatted string.


What is my number my number is a perfect square the only prime number and it prints at your location is to my number is a factor of 32 dozen of its digits is odd?

16


Where is the genetic material located in a cell and what is its function?

The genetic material is located in the nucleus. It stores the blue prints for all proteins and RNAs, which in turn perform every function in the cell.


What function print head?

print head is a device the prints directly on the media( paper, photo paper and tracing paper.


Write a program that input a positive integer and prints a triangle using for loop?

write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?


Who is Thomas prints?

thomas prints invented prints


What is cprintf?

A function in c langage that prints colored text one must use the heather file conio.h to use cprintf :)


What is definition for dry wet prints?

wet prints are those in which fabri is either dyed or printed dry prints are the fancy prints like flock prints, burn out prints.