Hi to all
I have a quick question. How can go through the integer to find if there is any specific number. For example my input would be 234446 (integer is of type long),and now I would like to check that integer and find how many 4's are in there and then display it.
Appreciate it

Thank for reply
but it don't work, try yourself, I'm sending you piece of code. No matter what numbers you pick, it is just not right (or maybe its me)

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
long n;
int found5,found8;
long digit;
found5=0;
found8=0;
cout<<"Enter an integer: ";
cin>>n;
while(n>0)
{
n=n/10;
digit=n%10;
if(digit==5)
found5++;
else
if (digit==8)
found8++;
}
cout<<"We have: "<<found5<<" 5's and we have: "<<found8<<" 8's";
getch();
return 0;
}

Doing it that way skips the single's digit if the number is found there as you are dividing the number by 10 before you modulus by 10 on the first iteration and check for 4.

Example: 3334 on the first iteration would be:
3334/10
333%10

check:
if( 3 == 4) false;
counter does not update, remains 0;

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...

Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.

This is the result of previous question answered :

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...