|
-
September 25th, 2007, 10:37 PM
#8
Re: i need help making this code work
okay lets start over my assignment is to add to this so it also tells me the largest and smallest of the integers. now im not asking for it to be done for me but i know next to nothing about programming
Then take our advice.
If you want to be a programmer, you should know what is standard and non-standard.
but im assuming i need to do an If statement similar to the above one but one that doesnt force me to change stdafx.h and such
There is no such file as "stdafx.h" in standard C++. So asking us to "not touch it" doesn't make sense. To many here, it doesn't even exist, and it will just interfere with you actually writing the program correctly.
Second, the entry point function for C++ programs is main(), not tmain(). I know you use Microsoft compilers, but you should know how to write your programs, independent of whether you're using a Microsoft compiler or not.
The following is a correct C++ program that will compile under any ANSI compliant C++ compiler.
Code:
#include <cstdio>
int main()
{
int Int1, Int2, Int3, sum, average, product;
//takes user input
printf("input three different integers: ");
scanf("%d%d%d", &Int1,&Int2,&Int3);
//equation process
sum = Int1 + Int2 + Int3;
average = sum / 3;
product = Int1 * Int2 * Int3;
//prints results
printf("Sum is %d\nAverage is %d\nProduct is %d\n", sum, average, product);
return 0;
}
Some things:
Turn off precompiled headers in your project settings. Get rid of the TCHAR stuff and _tmain() so that you know what a standard C++ program consists of.
Once you know what a standard C++ program is supposed to look like, then you can go and try precompiled headers, TCHAR or whatever other Microsoft specific things you want to try.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; September 25th, 2007 at 10:42 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|