Rabu, 01 April 2026

C++ From Year 1995 File From "M"

 // Filename: MATHMENU.CPP

// Uses a switch statement to perform

// menu actions for the user

#include <iostream.h>


void main()

{

  const int PI = 3.14159;

  int menu;       // Will hold menu result

  int num;        // Will hold user's numeric value

  float result;   // Will hold computed answer


  cout << "Math Calculations" << endl << endl;

  cout << "Please enter a number from 1 to 30: ";

  cin >> num;

  if ( (num < 1) && (num > 30));   

    {

      return;  // Exit if bad input

    }

    

  cout << "Here are your choices:" << endl << endl;

  cout << "\t1. Calculate the absolute value" << endl;

  cout << "\t2. Calculate the square" << endl;

  cout << "\t3. Calculate the cube" << endl;

  cout << "\t4. Calculate a circle's area" << endl;

  cout << "\t   using your radius" << endl;

  cout << endl << "What do you want to do? ";

  cin >> menu;


  switch (menu)

    { 

      case (1) : 

        { 

          result = ((num < 0)? -num : num);

          break;

        }

      case (2) : 

        { 

          result = num * num;

          break;

        }

      case (3) : 

        { 

          result = num * num * num;

          break;

        }

      case (4) : 

        { 

          result = PI * (num * num);

          break;

        }

      default  : 

        { 

          cout << "You did not enter 1, 2, 3, or 4" << endl;

          return;   // Terminate the whole program

                    // No need for a break

        }

    }


  cout << endl << "Here is your computed value: " 

       << result << endl;

  return;

}

==================================




// File Name : MFC.CPP

// A very simple Windows program

//

// To compile and run this, you will need to 

// use the MFC.MAK project included with the

// source. Choose Project | Open | MFC.MAK

//

#include<afxwin.h> // This lives in a different include 

                   // directory


//------------------------------------------------------------

// SimpleApp is a class that hides the Windows equivalent

// of main()

//

class SimpleApp:public CWinApp

 {

   public:

   BOOL InitInstance() // A virtual function - trust me!

      {

        CString title("Hello World");  // A string class

        title += "!"; // Classes can define operators too.

                      // Define the addition to concatenate

                      // a string.

        // Make a window object with a frame border

        CFrameWnd* mainWindow = new CFrameWnd;

        // Tell Windows to make a window

        mainWindow->Create(0,title);    

        // Assign the window to the application

        m_pMainWnd = mainWindow;               

        // Tell Windows to show the window

        m_pMainWnd->ShowWindow(m_nCmdShow);

        // Tell Windows to make sure that the window

        // is properly drawn.

        m_pMainWnd->UpdateWindow();

        // Tell the base application that we successfully

        // made a window

        return TRUE;

      }


  };



SimpleApp SimpleApp;  // This makes a global object

                      // which includes a main()

                      // that Windows can find

=========================================

             # Microsoft Visual C++ generated build script - Do not modify


PROJ = MFC

DEBUG = 0

PROGTYPE = 0

CALLER = 

ARGS = 

DLLS = 

D_RCDEFINES = -d_DEBUG

R_RCDEFINES = -dNDEBUG

ORIGIN = MSVC

ORIGIN_VER = 1.00

PROJPATH = C:\WORD6\VC12\SOURCE\

USEMFC = 1

CC = cl

CPP = cl

CXX = cl

CCREATEPCHFLAG = 

CPPCREATEPCHFLAG = 

CUSEPCHFLAG = 

CPPUSEPCHFLAG = 

FIRSTC =             

FIRSTCPP = MFC.CPP     

RC = rc

CFLAGS_D_WEXE = /nologo /G2 /W3 /Zi /AM /Od /D "_DEBUG" /FR /GA /Fd"MFC.PDB"

CFLAGS_R_WEXE = /nologo /G2 /W3 /AM /O1 /D "NDEBUG" /FR /GA 

LFLAGS_D_WEXE = /NOLOGO /ONERROR:NOEXE /NOD /PACKC:61440 /CO /ALIGN:16 /STACK:10240

LFLAGS_R_WEXE = /NOLOGO /ONERROR:NOEXE /NOD /PACKC:61440 /ALIGN:16 /STACK:10240

LIBS_D_WEXE = mafxcwd oldnames libw commdlg shell olecli olesvr mlibcew

LIBS_R_WEXE = mafxcw oldnames libw commdlg shell olecli olesvr mlibcew

RCFLAGS = /nologo

RESFLAGS = /nologo

RUNFLAGS = 

DEFFILE = MFC.DEF

OBJS_EXT = 

LIBS_EXT = 

!if "$(DEBUG)" == "1"

CFLAGS = $(CFLAGS_D_WEXE)

LFLAGS = $(LFLAGS_D_WEXE)

LIBS = $(LIBS_D_WEXE)

MAPFILE = nul

RCDEFINES = $(D_RCDEFINES)

!else

CFLAGS = $(CFLAGS_R_WEXE)

LFLAGS = $(LFLAGS_R_WEXE)

LIBS = $(LIBS_R_WEXE)

MAPFILE = nul

RCDEFINES = $(R_RCDEFINES)

!endif

!if [if exist MSVC.BND del MSVC.BND]

!endif

SBRS = MFC.SBR



all: $(PROJ).EXE $(PROJ).BSC


MFC.OBJ: MFC.CPP $(MFC_DEP)

$(CPP) $(CFLAGS) $(CPPCREATEPCHFLAG) /c MFC.CPP



$(PROJ).EXE:: MFC.OBJ $(OBJS_EXT) $(DEFFILE)

echo >NUL @<<$(PROJ).CRF

MFC.OBJ +

$(OBJS_EXT)

$(PROJ).EXE

$(MAPFILE)

c:\msvc\lib\+

c:\msvc\mfc\lib\+

$(LIBS)

$(DEFFILE);

<<

link $(LFLAGS) @$(PROJ).CRF

$(RC) $(RESFLAGS) $@



run: $(PROJ).EXE

$(PROJ) $(RUNFLAGS)



$(PROJ).BSC: $(SBRS)

bscmake @<<

/o$@ $(SBRS)

<<

====================================
NAME      MFC
EXETYPE   WINDOWS
CODE      PRELOAD MOVEABLE DISCARDABLE
DATA      PRELOAD MOVEABLE MULTIPLE
HEAPSIZE  1024
=============================
// Filename: MINMAX.CPP
// Finds the minimum and maximum values in an array

const int NUM = 20;

#include <iostream.h>

void prAra(int ara[NUM]);
int min(int ara[NUM]);
int max(int ara[NUM]);

void main()
{
  int ara[NUM] = {53, 23, 12, 56, 88,  7, 32, 41, 59, 91,
                  88, 62,  4, 74, 32, 33, 42, 26, 80,  3};
  cout << "Here is the array:" << endl;
  prAra(ara);
  cout << endl << endl << endl;
  cout << "The lowest value is " << min(ara) << endl << endl;
  cout << "The highest value is " << max(ara) << endl;

  return;
}
//**********************************************************
void prAra(int ara[NUM])
{
  int ctr;   // for-loop control variable
  for (ctr = 0; ctr < NUM; ctr++)
    { if ((ctr % 10) == 0)   // Print a newline after
        { cout << endl; }    // every 10 values
      cout.width(4);   // Print values in 4 spaces
      cout << ara[ctr];   // Print values in 4 spaces
    }
  return;
}
//**********************************************************
int min(int ara[NUM])
{
  int lowInt = 32767;
  int ctr;
  for (ctr = 0; ctr < NUM; ctr++)
    { if (ara[ctr] < lowInt)
        { lowInt = ara[ctr]; }
    }
  return lowInt;
}
//**********************************************************
int max(int ara[NUM])
{
  int highInt = -32768;
  int ctr;
  for (ctr = 0; ctr < NUM; ctr++)
    { if (ara[ctr] > highInt)
        { highInt = ara[ctr]; }
    }
  return highInt;
}
===========================
// Filename: MOREDIV.CPP
 // Computes two kinds of divisions and the modulus
 #include <iostream.h>
 void main()
 {
   int people, events, avgEv;
   int leftOver;        // Will hold modulus
   float floatPeople;   // Needed to force regular division
   float exact;         // Will hold exact average

   cout << "How many people will attend? ";
   cin >> people;
   cout << "How many events are scheduled? ";
   cin >> events;

   // Compute the integer average number of people per event
   avgEv = people / events;   // The integer division ensures
                              // that the fractional part of
                              // the answer is discarded
   cout << endl << "There will be an average of " << avgEv
        << " people per event." << endl;
   leftOver = people % events;
   cout << "There will be " << leftOver
        << " without an event at any one time." << endl;
   floatPeople = people;  // Converts the integer to a floating-point
   exact = floatPeople / events;
   cout << "The exact average number of people per event is "
        << exact;
   return;
 }
=============================
// Filename: MOVIES.CPP
// Stores and prints old movie titles
#include <iostream.h>

void main()
{
  int c;
  char * movies[] = {"To Italy Again!",
                     "Love Might Survive",
                     "My Computer and Me",
                     "Blabby",
                     "The First Man On Neptune"};
  cout << "Here are my all-time favorites:" << endl;
  for (c = 0; c < 5; c++)
    { cout << movies[c] << endl; }

  return;
}
===========================

Tidak ada komentar: