Sunday, April 15, 2012

Program 16TH in C++

PROBLEM STATEMENT :

Calculate number of zeros in a given integer.

SOLUTION :


#include <cstdio>
#include <iostream.h>

using namespace std;

int main()
{
int number;
int count=0;

cout<<"Enter an integer : ";
cin>>number;

while(number > 0)
{
count=count+(!(number%10)?1:0);
number=number/10;
}

cout<<"The number of zeros in the given number are : "<<count;


}

No comments:

Post a Comment