Output in hex please help

Discussion in 'C' started by nissignt, Dec 4, 2013.

  1. nissignt

    nissignt New Member

    Joined:
    Nov 9, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Karkov Ukraine
    Please help my output is not as required.There are Cs and Ds please help

    Code:
    #include <iostream>
    #include <cmath>
    #include<math.h>
    using namespace std;
    
    int main ()
    {   
    	int base ,power ,exponent,result = 1;
    	//exponent
    	//double x; double y;
    	double Quantity = 14;
    	double landa = 0.00014;
    	double MulticiplityRate = 4;
    	int time = 1000;
    
    	
    cout << "Enter the base" << endl;
    			cin  >> base;
    cout << "Enter the power" << endl;
    						cin  >> power;
    for(int i = 1 ;i <= power;i++)
    		exponent = result*base;
    
       cout << "The exponent  is " <<result<<endl;
       cout <<("Non-redundant system L :\n") << endl;
       for (double ml = 0.2; ml <= 1; ml += 0.2)
    		{
    			cout << ml << ("L ") << endl;
    			double nonRedundant = exponent * (-ml * landa * time);
    			cout << nonRedundant  << endl;
    		}
       cout << (L"Non-redundant system:\n") << endl;
    for (double m = 1; m <= MulticiplityRate; m += 1)
    		{
    			
    			cout << ("Whole-redundant system:\n") << endl;
    			for (double ml = 0.2; ml <= 1; ml += 0.2)
    			{
    				cout << ml << ("L ") << endl;
    				double Redundant = 1 - pow((1 - exponent*(-ml * landa * Quantity * time)), m + 1);
    				cout << Redundant << (L"\n") << std::endl;
    			}
    		}
    
    for (double m = 1; m <= MulticiplityRate; m += 1)
    
    		{
    			cout << (L"m=") << m  << (L";\n") << std::endl;
    			cout << (L"Per-element-redundant system:\n") << std::endl;
    			for (double ml = 0.2; ml <= 1; ml += 0.2)
    			{
    				cout << ml << (L"L ") << std::endl;
    				double Redundant = pow((1 - pow((1 - exp(-ml * MulticiplityRate * landa * time)), m + 1)), Quantity);
    				cout << Redundant << (L"\n") << std::endl;
    			}
    		}
    
    }
    OUTPUT ON SCREEN
    Code:
    Enter the base
    7
    Enter the power
    8
    The exponent  is 1
    Non-redundant system L :
    
    0.2L
    -0.196
    0.4L
    -0.392
    0.6L
    -0.588
    0.8L
    -0.784
    1L
    -0.98
    0086DCD8
    Whole-redundant system:
    
    0.2L
    -13.01750086DD30
    0.4L
    -41.09410086DD30
    0.6L
    -84.22980086DD30
    0.8L
    -142.4250086DD30
    1L
    -215.6780086DD30
    Whole-redundant system:
    
    0.2L
    -51.48170086DD30
    0.4L
    -272.1070086DD30
    0.6L
    -785.8420086DD30
    0.8L
    -1716.650086DD30
    1L
    -3188.510086DD30
    Whole-redundant system:
    
    0.2L
    -195.4910086DD30
    0.4L
    -1770.920086DD30
    0.6L
    -7263.120086DD30
    0.8L
    -20569.60086DD30
    1L
    -46948.50086DD30
    Whole-redundant system:
    
    0.2L
    -734.6630086DD30
    0.4L
    -11495.20086DD30
    0.6L
    -67061.40086DD30
    0.8L
    -2463530086DD30
    1L
    -6910960086DD30
    0086DD3410086DD3C
    0086DD44
    0.20086DD90
    0.8537970086DD30
    0.40086DD90
    0.5624180086DD30
    0.60086DD90
    0.3044430086DD30
    0.80086DD90
    0.1414310086DD30
    10086DD90
    0.05816920086DD30
    0086DD3420086DD3C
    0086DD44
    0.20086DD90
    0.9834750086DD30
    0.40086DD90
    0.8926020086DD30
    0.60086DD90
    0.7194880086DD30
    0.80086DD90
    0.5090610086DD30
    10086DD90
    0.316740086DD30
    0086DD3430086DD3C
    0086DD44
    0.20086DD90
    0.9982370086DD30
    0.40086DD90
    0.9775290086DD30
    0.60086DD90
    0.9110440086DD30
    0.80086DD90
    0.7865750086DD30
    10086DD90
    0.6178830086DD30
    0086DD3440086DD3C
    0086DD44
    0.20086DD90
    0.9998130086DD30
    0.40086DD90
    0.9954520086DD30
    0.60086DD90
    0.9738250086DD30
    0.80086DD90
    0.9173990086DD30
    10086DD90
    0.815120086DD30
    Press any key to continue . . .
     
  2. awnish

    awnish New Member

    Joined:
    Oct 6, 2015
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    pune
    //try this code
    Code:
    #include<stdio.h>
    void hex_to_int(long);
    
    int main()
    {
    	long ip;
    	printf("\n\tEnter a decimal number : ");
    	scanf("%ld",&ip);
    	printf("\n\tThe hexa-decimal number : ");
    	hex_to_int(ip);
    	printf("\n\n");
    }
    
    void hex_to_int(long num)
    {
    	int i=0;
    	long array[10] , temp ;
    	while(num%16)
    	{
    		array[i] = num%16;
    		num = num/16;
    		++i;
    	}
    	--i;
    	while(i>=0)
    	{
    		if(array[i]>9 && array[i]<16)
    			printf("%c",'A'+(char)(array[i]%10));
    		else
    			printf("%ld",array[i]);
    	--i;
    	}				 	
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice