Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <math.h>
- using namespace std;
- double a;
- double b;
- double c[9];
- double data;
- int count;
- int remaining_digits;
- int divideby;
- int get_divideby(int count){
- int output;
- switch(count){
- case 0:
- output = 1;
- return output;
- break;
- case 1:
- output = 10;
- return output;
- break;
- case 2:
- output = 100;
- return output;
- break;
- case 3:
- output = 1000;
- return output;
- break;
- case 4:
- output = 10000;
- return output;
- break;
- case 5:
- output = 100000;
- return output;
- break;
- case 6:
- output = 1000000;
- return output;
- break;
- case 7:
- output = 10000000;
- return output;
- break;
- case 8:
- output = 100000000;
- return output;
- break;
- case 9:
- output = 1000000000;
- return output;
- break;
- }
- }
- int main(){
- cout << "Input 10 bit control code: ";
- cin >> data;
- cout << "Input 10 bit code: " << data;
- count = 0;
- for (count; count<10; count++)
- {
- divideby = get_divideby(count);
- cout << "\nInput Data: " << data << "(Double)\n";
- cout << "Number = " << count << "\n";
- cout << "Dividing By: " << divideby;
- a = (data / divideby);
- cout << "A Process: " << a << "\n";
- b = fmod(a, 10); //Modulo cannot be used on doubles, so fmod is used instead.
- cout << "B Process: " << b << "\n";
- c[count]= floor(b); //Floor rounds the number down
- cout << "Final Output (C): " << c[count] << "\n";
- cout << "------------------------------------------\n";
- }
- if (count=9){ //Prints out array content
- for (count; count>=0; count--)
- {
- cout << "Array " << count << " :" << c[count] << "\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement