C++ Novice help

This is a discussion on C++ Novice help within the C++ Programming forums, part of the General Programming Boards category; I know the below code is riddled with errors. I am very new to C++ and I can run simple ...

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    10

    C++ Novice help

    I know the below code is riddled with errors. I am very new to C++ and I can run simple codes however this is my first time trying to do something this complicated. Well lets say complicated for me. Any help or suggestions are greatly appreciated.

    Code:
    # include <iostream>
    # include <string>
    # include <cmath>
    # include <math.h>
    
    using namespace std;
    
    
    float PerformanceTE (float a, float b, float c, float T){
    	  score = (a*(b-T)^c
    		return score;
    }
    
    float Performancej (float a, float b, float c, float M){
    	  score = (a*(M-b)^c
    		return score;
    }
    
    float PerformanceTH (float a, float b, float c, float D){
    	  score = (a*(D-b)^c
    		return score;
    }
    
    int main ()
    {
    
    float a[10] {25.4347, 0.14354, 51.39, 0.8465, 1.53775, 5.74352, 12.91, 0.2797, 10.14, 0.03768};
    float b[10] {18.00, 220.00, 1.50, 75.00, 82.00, 28.50, 4.00, 100.00, 7.00, 480.00};
    float c[10] {1.81, 1.40, 1.05, 1.42, 1.81, 1.92, 1.10, 1.35, 1.08, 1.85};
    float M;
    float T;
    float D;
    float string score[10];
    string name[5];
    float 100m;
    float Long jump;
    float Shot put;
    float High jump;
    float 400M;
    float time;
    float sum;
    
    cout<< " Welcome to the 2011 CSMC Decathlon"<< endl;
    cout<< " Day 1"<< endl;
    cout<< " Your first event will be the 100M dash"<<;
    cout<< " Enter your 100M dash time"<<;
    cin>> 100M;}
     T= 100m;
    
    if (100M < 9.58)
    {
    	cout<< " That's a new world record!";
    }
    else
    {
    	cout<<" Your score is!"<< PerformanceTE = a[1]*(b[1]-T)^c[1];
    
    	system("Pause");
    }
    return 0;
    {

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    What do you mean by "I can run simple codes" ?

    Programming has as much to do with 'running codes' as designing a hydraulic brake system has to with loading a garbage truck.

    If this is something you've concocted on your own(as opposed to ^C + ^V), I'd suggest you to start from scratch again.

    Keep the following points in mind:
    1. INDENT PROPERLY.
    2. Think about what you're doing, before 'doing'.
    3. Start by coding small parts of it at a time.
    4. The language has a syntax for a reason, not to haphazardly write whatever you want, like the following examples from your code.
    Code:
    score = (a*(b-T)^c
    
    float c[10] {1.81, 1.40, 1.05, 1.42, 1.81, 1.92, 1.10, 1.35, 1.08, 1.85};
    float High jump;
    float 400M;
     //....
    } return 0; {
    //.....
    Last edited by manasij7479; 08-21-2011 at 02:02 PM.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    Quote Originally Posted by genesis531501 View Post
    I know the below code is riddled with errors. I am very new to C++ and I can run simple codes however this is my first time trying to do something this complicated. Well lets say complicated for me. Any help or suggestions are greatly appreciated.
    Yes, your code is riddled with errors. Try looking at what the compiler is giving you for errors and warnings, find the line number it is talking about, and then fix the problem. Once you do that repost your code with any unresolved errors or warnings and then ask a specific question. This board is not a syntax checking service.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  4. #4
    -bleh-
    Join Date
    Aug 2010
    Location
    somewhere in this universe
    Posts
    455
    Get familiar with assignment '='.

    Code:
    float c[10] = {1.81, 1.40, 1.05, 1.42, 1.81, 1.92, 1.10, 1.35, 1.08, 1.85};
    That was one such instant in your code. now fix and figure out the rest.
    "All that we see or seem
    Is but a dream within a dream." - Poe

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Novice
    By AaronHall in forum C++ Programming
    Replies: 2
    Last Post: 06-20-2008, 05:48 PM
  2. Replies: 10
    Last Post: 06-17-2005, 10:00 PM
  3. Novice needs help
    By donniebb in forum C++ Programming
    Replies: 3
    Last Post: 02-01-2003, 04:50 PM
  4. help for a C novice
    By Unregistered in forum C Programming
    Replies: 8
    Last Post: 05-02-2002, 09:49 PM
  5. Please help a novice
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 01-08-2002, 09:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21