Help with warning

Posts 15 of 5 · Page 1 of 1
Help with warning
[PHP]//Program for Mastery

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
int result, result2, result3, result4, result5; //This lists the integers being used in the project.

//The formula used to get the absolute value
result = abs(result);
result2 = abs(result2);
result3 = abs(result3);
result4 = abs(result4);
result5 = abs(result5);

/*This is the console input and output to gain the absolute
value of the integer entered into the console.
It will display the absolute value after each entered value
*/
cout << "Enter first value:";
cin >> result;
cout << result << "\n";

cout << "Enter second Value: ";
cin >> result2;
cout << result2 << "\n";

cout << "Enter third value: ";
cin >> result3;
cout << result3 << "\n";

cout << "Enter fourth value: ";
cin >> result4;
cout << result4 << "\n";

cout << "Enter fifth value: ";
cin >> result5;
cout << result5 << "\n";

return 0;
}[/PHP]

Upon compilation, I receive these warnings:

Code:
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C
4530: C++ exception handler used, but unwind semantics are not enabled. Specify
/EHsc
c:\documents and settings\phil\my documents\visual studio 2008\projects\masteryp
roject.cpp(12) : warning C4700: uninitialized local variable 'result' used
c:\documents and settings\phil\my documents\visual studio 2008\projects\masteryp
roject.cpp(13) : warning C4700: uninitialized local variable 'result2' used
c:\documents and settings\phil\my documents\visual studio 2008\projects\masteryp
roject.cpp(14) : warning C4700: uninitialized local variable 'result3' used
c:\documents and settings\phil\my documents\visual studio 2008\projects\masteryp
roject.cpp(15) : warning C4700: uninitialized local variable 'result4' used
c:\documents and settings\phil\my documents\visual studio 2008\projects\masteryp
roject.cpp(16) : warning C4700: uninitialized local variable 'result5' used
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.
Any help would be appreciated.
Code:
//Program for Mastery

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
    int result, result2, result3, result4, result5; //This lists the integers being used in the project.

    /*This is the console input and output to gain the absolute
    value of the integer entered into the console.
    It will display the absolute value after each entered value
    */
    cout << "Enter first value:";
    cin >> result;
    result = abs(result);
    cout << result << "\n";

    cout << "Enter second Value: ";
    cin >> result2;
    result2 = abs(result2);
    cout << result2 << "\n";

    cout << "Enter third value: ";
    cin >> result3;
    result3 = abs(result3);
    cout << result3 << "\n";

    cout << "Enter fourth value: ";
    cin >> result4;
    result4 = abs(result4);
    cout << result4 << "\n";

    cout << "Enter fifth value: ";
    cin >> result5;
    result5 = abs(result5);
    cout << result5 << "\n";

    return 0;
}
Ohhh... Well, I sort of figured if you listed the formula's that it would be a bit better o.O

But, thanks a lot =D

Well, wouldn't there be a way to use the 'count' function in this?
To keep from typing the exact same thing 5 times over =o
Quote Originally Posted by Alroundeath View Post
Ohhh... Well, I sort of figured if you listed the formula's that it would be a bit better o.O

But, thanks a lot =D

Well, wouldn't there be a way to use the 'count' function in this?
To keep from typing the exact same thing 5 times over =o
Loops are you there yet? if yes, you could use it
Code:
int num;
for(int i=0; i<5; i++)
{
    cout<<"Enter number "<<i<<endl;
    cin>>num;
    cout<<"Abs: "<<abs(num)<<endl;
}
Posts 15 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?