Code for newbies to edit. [C++]

Posts 1–4 of 4 · Page 1 of 1
Code for newbies to edit. [C++]
I wanted my entrance to the programming forum to be helpful.
this is a short program I wrote people who are just learning C++ to edit.

Code:
// sample code
#include <iostream>
using namespace std;
int main ()
{
    // declaring variables
    int a, b, c;
    int result;
    // process
    a = 5;
    b = 3;
    a = 5 / 1;
    c = 10;
    a = c - 5;
    // result
    cout << result;
}
Quote Originally Posted by cod1 View Post
Code:
// sample code
#include <iostream>
using namespace std;
int main ()
{
    // declaring variables
    int a, b, c;
    int result;
    // process
    a = 5;
    b = 3;
    a = 5 / 1;
    c = 10;
    a = c - 5;
    // result
    cout << result;
}
This displays result, a variable which you haven't given a value to. Also, this will just flash by, to make it stop you need to add getch(), or system("PAUSE").
The display would be a junk value because you haven't initialized result with a value at all.
Sorry when I posted this I wasn't really that good at C++; I've read a few books and improved alot
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?