By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

Programming Forum

P: n/a
Hello Guys,
I've developed a forum for programmers and shareware developers to
discuss projects, sales, promotion and more. Please take a look if you
will at http://forum.codecall.net

Thanks,
Jordan

Jun 12 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 12 Jun 2006 09:01:09 -0700, jd*******@ionicware.com wrote in
comp.lang.c++:
Hello Guys,
I've developed a forum for programmers and shareware developers to
discuss projects, sales, promotion and more. Please take a look if you
will at http://xxxxx.xxxxxxxx.xxx
Utter and absolute garbage.

Example from
http://xxxxx.xxxxxxxx.xxx/c-c/201-ca...program-c.html, pasted
with "> " quotes, even though it was not part of the OP's post:

================ #include
Obviously somebody does not know how to convert header names to show
up properly in HTML.
float add(float,float);
float sub(float,float);
float product(float,float);
float divide(float,float);
void main()
Oops, undefined behavior in C, an ill-formed program in C++.
{
float n1,n2;
char sym,choice;
printf("This Program is a program for calculator\n\n");
scanf("%f%c%f",&n1,&sym,&n2);
Doesn't actually prompt for input, nor explain the expected format of
that input. Doesn't take into account the poor behavior of scanf()
with live user input, let alone the potential undefined behavior.
if(sym=='+')
printf("\n%f",add(n1,n2));
if(sym=='-')
printf("\n%f",sub(n1,n2));
if(sym=='*')
printf("\n%f",product(n1,n2));
if(sym=='/')
printf("%f",divide(n1,n2));
printf("\nDo you wish to continue[y/n]");
scanf("%s",&choice);
Uses "%s" conversion specifier to scanf() with the address of a single
character, guaranteed memory overwrite and undefined behavior.
if(choice=='y'||choice=='Y')
main();
Calls main() recursively to loop?!? Yikes!?!
}
float add(float m1,float m2)
{
return(m1+m2);
}
float sub(float m1,float m2)
{
return(m1-m2);
}
float product(float m1,float m2)
{
return(m1*m2);
}
float divide(float m1,float m2)
{
return(m1/m2);
}


The output may not appear without a terminating '\n', and the leading
'\n' is of questionable utility.

What a waste of web space.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jun 13 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.