C++ Help

shit, i took C++ last year in highschoolmade a program for determining port sizes

all that shit

dice rolling programs for D&D

all that fun shit

and some semi-useful shit

some text based games too

too bad all of it got erased when the school's network got butt****ed over the summer

C++ was fun but its pretty much a dead coding language

alot of highschools dont even teach it anymore

learn java
Dead.

LMAO, you don't know WTF you are talking about tard.

nG

 
Code:
/******************************************************************************/
/*********************************Chad Hicks***********************************/
/***************************     Real to Unsigned  ****************************/
/**************************Written Using Dev-C++ Ver4**************************/
/************************* Written on October 28th 2007************************/
/**************************For Math 240 Alan Smothers**************************/
/*****************************At Concord University****************************/
/******************************************************************************/




#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <fstream>
#include <string>
#include <iomanip>

using namespace std;
 // Function Prototypes
 void printbinary(int length, unsigned int* passed, unsigned int value);
 void printhex (int length, unsigned int* passed,unsigned int value);
 int addary (int ary[],int counter,int sum);
 bool testp (string testof, int length,int beg);

 int main()

 {
 string pal;

 int ary1[10];
 for (int countit =0; countit<10; countit++)
     ary1[countit] = countit;

 bool returned;
 float* x;
 unsigned int* y;
 unsigned int value2 = 1; //Initializes the comparision variable to 1 followed by 31 zeros
 cout<<"Input Float Value:     ";
 cin>>*x;  //Input of Floating Value into the address that x points to
 cout<<endl;

 /****************************************************************************/
 /*  This line of code does 99% of the work for this assignment.  It takes   */
 /*  the float pointer x and reinterprets into integer through the y pointer */
 /****************************************************************************/
 y = reinterpret_cast<unsigned int*>(x);

 cout<<"Decimal:     "<<*y<<endl<<endl; //Output the translated float variable as a integer decimal

 cout<<"Binary:      ";
 printbinary(0, y, value2); //printbinary call, this function prints the binary representation of the floating point, how it literally looks in memory
 cout<<endl<<endl;

 cout<<"Hex:         ";
 printhex(0,y,0x80000000); //print hexcall, this function prints the hex represntation of the float variable, how it physically looks in memory
 cout<<endl<<endl;

 int sumit = addary(ary1,10,0);
 cout<<"Array Sum:     "<<sumit<<endl<<endl;

 cout<<"Input String to be tested for palindrome"<<endl;
 cin.getline(pal);

 int l = pal.length();
 l--;

 returned  =  testp(pal,l,0);
 system("PAUSE");

 return(0);
 }

 /****************************************************************************/
 /*     This function recieves length, which is the length of the size of    */
 /*     your float memory location.  It also receives a pointer to a         */
 /*     unsigned integer holding the binary representation of the float.     */
 /*                                                                          */
 /*     This function takes the binary representation, does a comparision    */
 /*     then outputs the number in binary                                    */
 /****************************************************************************/
 void printbinary (int length, unsigned int* passed, unsigned int value)
      {
      bool test = 0;
          if (length<=31)
             {
             printbinary (length+1,passed, value <<1);
             test = value & *passed;  // this & comparison compares the comparision variable to the binary representation in the unsigned int
             cout<<test;
//              value = value >> 1; //this shifting moves the comparision 1 down 1 to compare the next bit position
             }
          else
             {
             return;
             //printbinary (length++, passed, value);
             }


//       cout<<endl<<endl;
      }

 /****************************************************************************/
 /*     This function recieves length, which is the length of the size of    */
 /*     your float memory location.  It also receives a pointer to a         */
 /*     unsigned integer holding the binary representation of the float.     */
 /*                                                                          */
 /*     This function takes the binary representation, breaks it up into 4   */
 /*     then translates that into hex and prints it                          */
 /****************************************************************************/
 void printhex(int length, unsigned int* passed, unsigned int value)
      {

      int a = 8;//a is used in the mathmatical compilation of the hex variable, since 1000 in binary =8
      bool test = 0; // this is used to check if a bit is 1 or 0
      int countit = 0; //countit is used in the compilation of the hex variable

      if (length < 8)
//       for (int loop = 0; loop < 8; loop++)//outer loop is for the different hex values
          {
          for (int loop2 = 1; loop2 < 5; loop2++)//inner loop is to compute a single hex variable
              {
              test = value & *passed; //bit comparision
//               cout<<value<<"   "<<*passed<<"    "<<test<<endl;
              if (test == true)
                   countit = countit + a;// if a bit is 1 then a is added to countit
              a=a>>1; // a is shifted down from 8 to 4 to 2 to 1 in this loop. This allows for hex to be computed correctly
              value = value >> 1; // shifting of the comparision variable
              }

          switch ( countit )  // This switch is to output the Hex for each variable
             {
             case 10: cout<<'A';
                      break;
             case 11: cout<<'B';
                      break;
             case 12: cout<<'C';
                      break;
             case 13: cout<<'D';
                      break;
             case 14: cout<<'E';
                      break;
             case 15: cout<<'F';
                      break;
             default: cout<<countit;
                      break;
             }

          countit = 0; //countit is reset to zero for the next hex variable
          a = 8;  //countit is reset to 8 for the next hex variable
          printhex(length+1, passed, value);
          }
//       cout<<endl<<endl;
      }

int addary (int ary[],int counter,int sum)
   {
   sum= sum+ary[counter-1];
   if (counter == 2 )
      return sum;
   else
      return addary(ary,counter-1,sum);
   }

bool testp (string testof, int length, int beg)
    {
    cout<<beg<<"     "<<length<<endl;
    if (beg>=length)
       {
       cout<<testof<<" is a palindrome!"<<endl;
       return 1;
       }
    else
        {
        if (testof[beg]!=testof[length])
           {
           cout<<testof<<" is NOT a palindrome!"<<endl;
           return 0;
           }
        else
            testp(testof,length-1,beg+1);
        }
    }
heres the entire program if your wanting to see it noah //content.invisioncic.com/y282845/emoticons/smile.gif.1ebc41e1811405b213edfc4622c41e27.gif

 
Just because java is prettier dont mean its better //content.invisioncic.com/y282845/emoticons/smile.gif.1ebc41e1811405b213edfc4622c41e27.gif

c++ is the driving force for pretty much everything

i also know pascal, now thats a dead language

 
shit, i took C++ last year in highschoolmade a program for determining port sizes

all that shit

dice rolling programs for D&D

all that fun shit

and some semi-useful shit

some text based games too

too bad all of it got erased when the school's network got butt****ed over the summer

C++ was fun but its pretty much a dead coding language

alot of highschools dont even teach it anymore

learn java
My *** c++ is dead... every university is going to teach you either Jave or C++ as your core language. Don' talk till you get to college noob or get into the industry.

 
Activity
No one is currently typing a reply...

About this thread

lilmaniac2

5,000+ posts
Ask Me about SI Mag V4!
Thread starter
lilmaniac2
Joined
Location
Somewhere, Else
Start date
Participants
Who Replied
Replies
22
Views
437
Last reply date
Last reply from
ngsm13
IMG_20260506_140749.jpg

74eldiablo

    May 22, 2026
  • 0
  • 0
design.jpeg

WNCTracker

    May 22, 2026
  • 0
  • 0

New threads

Top