problem in creating a problem

I read all the sections of identifiers and conditional structures but I am still having a problem in creating a program.I want to run a program that calculates the area of circle while asking for the radius from the users using float.and it should not stop unless the user ask it to stop .
I will be thankfull if you tell me this .
you can create an infinite loop and break it if the user wants to stop

eg:
1
2
3
4
5
6
7
8
9
while(true)
{
    //your stuff

    //ask the user if he wants to stop
    if ( user_wants_to_stop )
        break; //exit the loop
}
Thank you !
but can you tell me where should i give cout <<
please give the entire program.I will be very thankfull
I'm not a fan of infinite loops used for this purpose. I would rather see the breaking condition specified in the while statement itself...

1
2
3
4
while( !user_wants_to_stop )
{
    //the stuff
}


Either way works and no offense to anyone who may prefer the infinite loop; I'm just surprised they are suggested as often as they are.
Please answer this question too !
I am still having a problem in creating a program.I want to run a program that calculates the area of circle while asking for the radius from the users using float.
thanks and best regards !
@seymore15074
I prefer using while(true) so that I don't have to use an extra variable and because I can break it any time (without having to reach the next loop).

@masiht
Where are you getting problems?

Last edited on
@Bazzy

Interesting. I work under coding standards that forbid breaks; possibly for maintanability concerns. Also forbidden are multiple returns from a function, jumps, etc. It's one of the things in their standards that I agree with. Thanks for the input.

@masiht

If you have not started your assignment, begin by making an ordered list of what you have to do. Then start coding the basic structure of the program. When you encounter problems, post what you have, and we'll help you out.
Last edited on
#include <iostream>
using namespace std;

#define PI 3.14159


int main ()
{
double r; // radius
double area;
cout <<"enter the radius value";
cin >>r;
area = PI * r*r;
cout << circle;

return 0;
}

this program is giving this errror
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
C:\Users\Pro Standard F.S Co\Desktop\SF grasscut\oscar\aaaaa\Debug\aaaaa.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Users\Pro Standard F.S Co\Desktop\SF grasscut\oscar\aaaaa\aaaaa\Debug\BuildLog.htm"
aaaaa - 2 error(s), 0 warning(s)
Last edited on
It calculates the circumference, not the area. Ok, so you need to do that repeatedly, using a while loop (actually a do while would be nice here).
and lets say that I dont want the user to enter the radius not more than 5 cm. if they enter radius value above above 5 , the system gives the messege " your value is not in our range"
if they enter radius value above 5 , the system gives the message "your value is not in our range"
1
2
if (radius value is greater than 5) 
   show "your value is not in our range"

Just translate that in C++
@ bazzy Thanks alot
Can you tell me what is wrong with this program

#include <iostream>
using namespace std;

#define PI 3.14159


int main ()
{
double r; // radius
double area;
cout <<"enter the radius value";
cin >>r;
area = PI * r*r;
cout << circle;

return 0;
}

this program is giving this errror
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
C:\Users\Pro Standard F.S Co\Desktop\SF grasscut\oscar\aaaaa\Debug\aaaaa.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Users\Pro Standard F.S Co\Desktop\SF grasscut\oscar\aaaaa\aaaaa\Debug\BuildLog.htm"
aaaaa - 2 error(s), 0 warning(s)
cout << circle; should be cout << area;

The linker error seems to depend on some wrong compiler option.
Which compiler are you using?
microsoft visual c++ express


this is the error now

MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
C:\Users\Pro Standard F.S Co\Desktop\SF grasscut\oscar\yyyyy\Debug\yyyyy.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Users\Pro Standard F.S Co\Desktop\SF grasscut\oscar\yyyyy\yyyyy\Debug\BuildLog.htm"
yyyyy - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited on
closed account (z05DSL3A)
Try changing the "subsystem" in your linker settings from "Windows" to "Console".
@ bazzy I went there here is what it says there

/OUT:"C:\Users\Pro Standard F.S Co\Desktop\SF grasscut\oscar\tttttt\Debug\tttttt.exe" /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"Debug\tttttt.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Pro Standard F.S Co\Desktop\SF grasscut\oscar\tttttt\Debug\tttttt.pdb" /SUBSYSTEM:WINDOWS /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
/OUT:"C:\Users\Pro Standard F.S Co\Desktop\SF grasscut\oscar\tttttt\Debug\tttttt.exe" /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"Debug\tttttt.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Pro Standard F.S Co\Desktop\SF grasscut\oscar\tttttt\Debug\tttttt.pdb" /SUBSYSTEM:WINDOWS /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib


As Grey Wolf said change the
Property Page > ... > Linker > System > SubSystem to Console
Last edited on
@ buzzy thanks alot it works now
@ grey wolf , Thanks to you too.
Topic archived. No new replies allowed.