C S C O R N E R

Heavy Decimal Count Problem Solving in C++

/*******************************************************************
******* This program is written using Dev C++ ******
******* By Tasaddaq Hussain (+RANA G+) ******
******* Bc110200816@gmail.com | Sialkot | BSC ******
**********************************************05 May 2016**********/
 
#include<iostream>
#include<conio.h>
#include<stdio.h>
 
using namespace std;
 
void Avg_func(); //FUNCTION prototype
 
int main(void)
{
 
cout<<"\n\n ********** HEAVY DECIMAL COUNTER ********** \n\n\n";
 
Avg_func(); //Calling function
 
getch();
 
return 0;
}
 
void Avg_func() //Function definition
{
int lower_no, uper_no, remainder; //Declaring Lower number and Uper number
 
 
cout<<"Please enter Lower Number: "; //geting lower and upper number from user
cin>>lower_no;
 
cout<<"Please enter Upper Number: ";
cin>>uper_no;
 
cout<<"\n\nNumbers Average Heavy\n\n\n"; //printing lists headings
 
while(lower_no <= uper_no) //until lower is lesser than upper number
{
int temp = 0;
 
float avarage;
float digits[6]; //to store digits
int count = 0; // to count how many digits are in the enterd number
 
for(int y = 0; y<6; y++) //initializating all index to zero
{
digits[y] = 0;
}
 
temp = lower_no; //dont wanna distroy no's value so storing that in temp variable for further calculations
 
while(temp)
{
remainder = temp%10; // getting last digit from number
 
temp = temp/ 10; //separating / deleting last digit from number
 
digits[count] = remainder; // storing got digits in indexes
count++;
}
 
avarage = (digits[0]+digits[1]+digits[2]+digits[3]+digits[4]+digits[5])/(count); //average calulation
 
cout<<"\n"<<lower_no; //printing outputs in sequence /table
cout<<"\t\t"<<avarage<<"\t\t";
 
(avarage <= 7)? cout<<"NO" : cout<<"Yes"; //checking is it heavy no or not
 
lower_no++; // increasing to 1 to get next number .... and perform all calculations for next number.
 
}
}


CODE FILE:
Download link: Click Here
OUTPUT:

No comments:

Powered by Blogger.