Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C++/C Programming › average

average

Posts 1–15 of 24 · Page 1 of 2
LA
lalakijilp
average
as a "Mastery Check" for chapter 1 of a tutorial
i needed to make a program that can calculate the average of 5 values.
after doing this (easypeasylemonsqueezy) i tried to make a program that can calculate the average of more values (you can enter te amount of values).
the result was this.
the only problem is it doesn't work
can someone explain how to make it work?

#include <iostream>
using namespace std;

int main ()
{
int amount;
double result, value, tellen;
result = 0;

cout << "put in the amount of values you want the average of: ";
cin >> amount;
cout << endl;

for(tellen = 1; tellen <= amount; tellen++)
{
cout <<"Put in the " << amount << " number.";
cin >> value;
cout <<endl;
result + value = result; //what is wrong with this line?

}

cout << "The average is " << result/amount <<"." <<endl;

system ("pause");

return 0;
}


#1 · 17y ago
Corndog
Corndog
what do u mean by it doesnt work? cause i get a syntax error when i try to compile...is that what the problem was?
nvm, i see where u put a comment.
#2 · 17y ago
LA
lalakijilp
Quote Originally Posted by Corndog View Post
what do u mean by it doesnt work? cause i get a syntax error when i try to compile...is that what the problem was?
yeah it is a problem when it doesn't work
my compiler thinks this is the problem.
could u plz find the mistake in my code

result + value = result;
#3 · 17y ago
Corndog
Corndog
okay. heres ur problem. you have it saying:
result + vaule = result

But C++ is very picky. you need it to be like this:
result = result + value

and it works good, besides the way it says "put in the 2 number" if i want it to average out 2 numbers...it just looks weird.
#4 · 17y ago
LA
lalakijilp
Quote Originally Posted by Corndog View Post
okay. heres ur problem. you have it saying:
result + vaule = result

But C++ is very picky. you need it to be like this:
result = result + value

and it works good, besides the way it says "put in the 2 number" if i want it to average out 2 numbers...it just looks weird.
i'll go change it to "put in number 2"

why does it need to be in that order?
#5 · 17y ago
Corndog
Corndog
i am not sure why...but it just does.

and you dont have to change the wording...it just seemed weird to me.
#6 · 17y ago
LA
lalakijilp
i replaced it by this and now it is working perfectly

cout <<"Put in number " << tellen << " : ";
#7 · 17y ago
Corndog
Corndog
okay. i just changed the cout line with this. i think it looks better.

cout << "You Want The Average of " << amount << " Numbers. Please Enter One of These Numbers: ";
#8 · 17y ago
LA
lalakijilp
cout << "Please enter number " << tellen << "/" << amount << ":"
#9 · 17y ago
Corndog
Corndog
yep that works too...glad i could help you with ur problem.

okay. good luck with chapter 2, 3, and so on.
#10 · 17y ago
LA
lalakijilp
ty
#11 · 17y ago
why06
why06
Glad you got that worked out.

Just FYI:
The assignment operator ("=") isn't the same as the equals sign in mathematics. This is very important.

It only works one way. whatever value that is on the right once calculated will be added to the left. This works the same way for many things. Imagine if you used the input operator for the cout statement the way you used the assignment operator:

"Hi ">> "There" >> cout;

This would absolutely not work. so just get used to this aspect of programming. In almost all English versions of programming languages. the math (adding, sub, mult.) is done on the right and then assigned to the left. This is universal.
#12 · 17y ago
Corndog
Corndog
thx Why06. i didnt really know how to explain it...just knew it wouldnt work, lol.
#13 · 17y ago
Zhhot
Zhhot
Quote Originally Posted by lalakijilp View Post
as a "Mastery Check" for chapter 1 of a tutorial
i needed to make a program that can calculate the average of 5 values.
after doing this (easypeasylemonsqueezy) i tried to make a program that can calculate the average of more values (you can enter te amount of values).
the result was this.
the only problem is it doesn't work
can someone explain how to make it work?
PLEASE READ THE COMMENTS, IDK IF IM RIGHT OR WRONG

Code:
#include <iostream>
using namespace std;

int main ()
{
int amount;
double result, value, tellen;
result = 0;

cout << "put in the amount of values you want the average of: ";
cin >> amount;
cout << endl;

for(tellen = 1; tellen <= amount; tellen++)
{
cout <<"Put in the " << amount << " number."; // rnt u supposed to give space after << 
cin >> value;
cout <<endl; // u didnt give space between << and endl
result + value = result; 

}

cout << "The average is " << result/amount <<"." <<endl; // shouldnt it be << "." << endl;
system ("pause");

return 0;
}
Is that y u are getting syntax error?
#14 · edited 17y ago · 17y ago
ZE
zeco
result + value = result didn't work because in C++ using '=' indicates that you are passing the value of the expression on the right side, to the variable or whatever on the leftside
#15 · 17y ago
Posts 1–15 of 24 · Page 1 of 2

Post a Reply

Similar Threads

  • The average price of weedBy Zeinland in Reefer Club
    46Last post 16y ago
  • The average price of weedBy Zeinland in General
    5Last post 17y ago
  • l9 ROF to average ARBy Dr.Dental in Combat Arms Mod Discussion
    1Last post 16y ago
  • How long do you spend on average on a sig?By shaheenster in Art & Graphic Design
    15Last post 16y ago
  • How to work out the average EXP and GP You get in a year.By Spookerzz in Combat Arms Discussions
    20Last post 16y ago

Tags for this Thread

#average