Staredit Network

Staredit Network -> Miscellaneous -> need a c++ code example
Report, edit, etc...Posted by illusion(SS) on 2005-10-18 at 13:27:48
im doing something for school and need an example of some c++ code. anything, about like the size of a small paragraph
Report, edit, etc...Posted by synd][cate on 2005-10-18 at 13:44:37
CODE

// I am a C++ program

#include <iostream.h>

int main ()
{
 cout << "Hello World! ";
 cout << "I'm a C++ program";
 return 0;
}
Report, edit, etc...Posted by Staredit.Net Essence on 2005-10-18 at 14:59:58
I would use <iostream> instead of <iostream.h>.
Report, edit, etc...Posted by Staredit.Net Essence on 2005-10-18 at 15:12:49
QUOTE(Gradius @ Oct 18 2005, 12:59 PM)
I would use <iostream> instead of <iostream.h>.
[right][snapback]336317[/snapback][/right]


Yes.

Also, I wouldn't help the guy cheat...
Report, edit, etc...Posted by notnuclearrabbit on 2005-10-18 at 21:21:57
[center]Liek ah mah gad, a skeletal .nib app! It's mac, so meh.
CODE
#include <Carbon/Carbon.h>

int main(int argc, char* argv[])
{
   IBNibRef   nibRef;
   WindowRef   window;
   
   OSStatus  err;

   err = CreateNibReference(CFSTR("main"), &nibRef);
   require_noerr( err, CantGetNibRef );
   
   err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
   require_noerr( err, CantSetMenuBar );
   
   err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &window);
   require_noerr( err, CantCreateWindow );

   DisposeNibReference(nibRef);
   
   ShowWindow( window );
   
   RunApplicationEventLoop();

CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
return err;
}
[/center]
Report, edit, etc...Posted by Kashmir on 2005-10-18 at 21:34:48
This is a Console (.NET) program

CODE
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;

void DisplayWelcome();
void DisplayProjectedValue(double amount, int years, double rate);
double GetInvestmentAmount();
int GetInvestmentPeriod(int min = 10, int max = 25);

void DisplayWelcome()
{
Console::WriteLine(S"\n\n\no------------------------------o");
Console::WriteLine(
 S" Welcome to Investment Planner!");
Console::WriteLine(S"o------------------------------o");
return;
}

void DisplayProjectedValue(double amount, int years, double rate)
{
double rateFraction = 1 + (rate/100);
double finalAmount = amount * Math::Pow(rateFraction, years);
finalAmount = Math::Round(finalAmount, 2);

Console::Write(S"Investment amount: ");
Console::WriteLine(amount);
Console::Write(S"Growth rate [%] ");
Console::WriteLine(rate);
Console::Write(S"Period [years]: ");
Console::WriteLine(years);
Console::Write(S"Projected final value of investment: ");
Console::WriteLine(finalAmount);
return;
}

double GetInvestmentAmount()
{
Console::Write(S"How much money do you want to invest? ");

String __gc * input = Console::ReadLine();
double amount = input->ToDouble(0);
return amount;
}

int GetInvestmentPeriod(int min, int max)
{
Console::Write(S"Over how many years [");
Console::Write(S"min = ");
Console::Write(min);
Console::Write(S", max = ");
Console::Write(max);
Console::Write(S"] ? ");

String __gc * input = Console::ReadLine();
int years = input->ToInt32(0);
return years;
}

int _tmain()
{
   DisplayWelcome();

Console::WriteLine(S"\nIllustration...");
DisplayProjectedValue(10000, 25, 6.0);

Console::WriteLine(S"\nEnter details for your investment:");
double sum = GetInvestmentAmount();
int period = GetInvestmentPeriod(5, 25);

Console::WriteLine(S"\nYour plan...");
DisplayProjectedValue(sum, period, 6.0);

_tmain();
return 0;
}
Report, edit, etc...Posted by illusion(SS) on 2005-10-18 at 22:00:52
thanks, you guys have satified my needs.
>>Locked
Next Page (1)