ndeniche 402 Posting Virtuoso Featured Poster

thank you very very much...

ndeniche 402 Posting Virtuoso Featured Poster

yup... just when they said my reasons for smoking were the stupidest they've ever heard...:@ (i wonder who was that:confused: )...

ndeniche 402 Posting Virtuoso Featured Poster

what about fat people? are you gonna tell me there is nothing genetic there?

ndeniche 402 Posting Virtuoso Featured Poster

that is different, since building a body doesn't involve any addicion...

see it this way... you have a need for smoke... you body asks you t smoke... chances are, your son's body also asks him to smoke, even worse if you smoke in his presence...

ndeniche 402 Posting Virtuoso Featured Poster

>>So if it's genetic, can we outlaw cheeseburgers for all people?
???

ndeniche 402 Posting Virtuoso Featured Poster

actualy i'd say that's more like a genetic trait... i mean... if your parents smoke, chances are you will smoke too... even if your grand parents did and your parents don't, you have big chances of smoking too... i've seen that happen...

ndeniche 402 Posting Virtuoso Featured Poster

because it is a self provoked death... is like suicide...

ndeniche 402 Posting Virtuoso Featured Poster

the thing is that the smokers society is one of the most generous societies there is... we even say "a cigar is like water... you don't deny it to anyone..."

ndeniche 402 Posting Virtuoso Featured Poster

the thing is... if you are in an open place, where air can flow freely, i can't find any inconvenience with smoking (besides the obvious own harm and lung frying)

ndeniche 402 Posting Virtuoso Featured Poster

have you heard saying that a passive smoker dies faster thatan active smoker...

well, let's just say i smoke to avoid being a passive smoker... :D

ndeniche 402 Posting Virtuoso Featured Poster

ok... i certainly know smokers will be with me in this...

i've got reasons to smoke: pay attention...

first, i'm elping to make this planet a better place for my children, or lets say the children of the children of the children of my children, since, the more cigarrettes i smoke, the more the cigar industry grows, and when a market grows, it means more production... and with more prouction, there is more tobacco... and with more tobacco, there is less food for tobacco... so, what will happen when the soil runs out of minerals for tobacco? it will not be possible to keep growing tobacco, and there will be no more cigars in the world... and, some might say, why not just buy the cigars and throw them away? well, that's because i'm not throwing away my money, so if i buy something, i use it...

second: i am preparing myself to extreme conditions... how do athletes prepare their body for competitions? going through heavy sessions of exercises... so... the same way athletes exercise their muscles for extreme situations... i prepare my lungs for extreme siuations... say, someone's house is burning... a non-smoker would not be able to survive all that smoke caused by the fire, but, a smoker, since has been preparing his lungs by providing them doses of smoke IS prepared to receive that smoke from the fire, and enter the house and save, say a child that is trapped, hiding under the dinning …

WolfPack commented: Makes perfect sense to me. +10
Salem commented: Parody is fun +9
ndeniche 402 Posting Virtuoso Featured Poster

but, the thing is... it depends on the restaurant you go to... i think no one would be as idiotic to go and smoke at a McDonalds... but if you're at Ruby Tuesday's for example, that's why they have a smokers and non smokers section...

ndeniche 402 Posting Virtuoso Featured Poster

what the heck are you talking about?

ndeniche 402 Posting Virtuoso Featured Poster

it's not like i would smoke while having a meal at some restaurant... but, i don't find anything wrong about smoking on a street or an open place...

ndeniche 402 Posting Virtuoso Featured Poster

the problem is that in arrays of arrays all arrays have the same length, meaning the same quantity of elements, in this case, ints...

that's why i proposed the idea of using a struct with an int and an array of ints, where the int specifies the length of the array...

ndeniche 402 Posting Virtuoso Featured Poster

what about doing it with a struct? this way every array is independent from the other, so you can create an array of structs...

now, what i would find complicated is instructing the structs the size of the array of ints... maybe creating an int variable in the struct that indicates the size of the array...

ndeniche 402 Posting Virtuoso Featured Poster

thank you very much for the explanation... i've been asking this to all of my teachers and none of them has had a convincing answer...

thnks :)

ndeniche 402 Posting Virtuoso Featured Poster

though not every compiler accepts the same syntax at all... or even the same libraries... for example... i've had a really bad time passing from dev to turbo c++...

ndeniche 402 Posting Virtuoso Featured Poster

i tried it in borland's turbo c++ and bloodshed's dev c++... none of both gave me errors... not with main, neither with void main...

ndeniche 402 Posting Virtuoso Featured Poster

i'll probably get yelled at or even -repped, but, @ my university they don't even use a type for main... they just start the main as main(){ ... i know this is wrong, but, what is its effect?

ndeniche 402 Posting Virtuoso Featured Poster

ok... look...

when you initialize a variable with no values, this variables has a random value stored in it. in your program, you assign values to your variables until the end, where you have your switch...

what you have to do is the following:

#include <iostream>
using namespace std;
int main(void)
{
    int a,b,c,d,radius,volumeprism;//see how you can declare
                                   //several variables at the
                                   //same time
    double volumesphere;//volumesphere must be declared as a
                        //double so it returns decimal values

    cout << "Welcome to the program!\n\n";
    cout << "Do you want the volume of:\n";
    cout << "1. Cube\n";
    cout << "2. Sphere\n";
    cout << "3. Exit\n";
    cin >> a;
    switch (a)
    {
    case 1:
        cout<<"enter length";
        cin >> b;
        cout<<"enter height";
        cin >> c;
        cout<<"enter width";
        cin >> d;
        volumeprism=b*c*d;//the math operation you had @ the
                          //beginning goes here so it multiplies
                          //the values you want it to multiply
        cout << volumeprism;
    break;

    case 2:
        cout << "enter radius";
        cin >> radius;
        volumesphere=1.333333333333*3.1415926536*(radius^3);

        //here's the other math operation you had up there

        cout << volumesphere;
    break;

    case 3:
        return 0;
    break;
    }
    
    return 0;
}

and that should do the trick...

the problem is you thought a mathematical operation done in a variable would be done every time you gave different values to variables...

well... that doesn't happen in c++ (or even any other languages)...

ndeniche 402 Posting Virtuoso Featured Poster

yup, you should give values to a,b, c and radius before using them in a mathematic operation...

int a;//you
int b;//are
int c;//not
int radius;//giving any values to these variables
int volumeprism;
volumeprism=a*b*c; //so when you use them here, 
//it will give you random numbers,
//or what we call junk

got it?

ndeniche 402 Posting Virtuoso Featured Poster

first of all, the first warning (the one that says about double and int) means that you are initializin an integer (whole number) with values of a double number (a number with decimal points and extreme accuracy)... so, you should initialize your variable as a float or double...

ndeniche 402 Posting Virtuoso Featured Poster

ja!!! i'm on fire!!!!

>>I'm sure you'll say something stupid
>>eventually and things will be back to normal

Thank you... i'm flattered

ndeniche 402 Posting Virtuoso Featured Poster

you must be in a really good mood today... i had never seen two consecutive agreements with me in anything...

ndeniche 402 Posting Virtuoso Featured Poster

>why don't you better use cin and cout?
Agreed. Perhaps this thread is in the wrong forum and he's really using C.

finally wee agree on something...

by the way... i'm not yet too familiar with using printf and scanf... since i've always worked with cin and cout... and i prefer using those because the other two are two tricky to use, and trigger lots and lots of problems...

ndeniche 402 Posting Virtuoso Featured Poster

why don't you better use cin and cout?

either way, it would be like this: scanf("%s",&word);

ndeniche 402 Posting Virtuoso Featured Poster

man... you have serious problems with basic c++ programming...

first, you have no need of using that much variables... i guess three variables will be enough...

second... why all those validations? i really don't understand what is the idea before every while loop...

perhaps you should consider wrapping your text in code, that way, we could read it better...

ndeniche 402 Posting Virtuoso Featured Poster

there are two things you could do to help those who want to help you...

first of all, wrap your text in code tags[[B]code=c[/B]][[B]/code[/B]]...

second, try using a title that suggests what your problem is next time...

ndeniche 402 Posting Virtuoso Featured Poster

Why would it give you an error?

You said 'char*' and not 'const char*', so it's perfectly reasonable from a syntactic point of view to allow you to modify what it points to.

thank you... thank you very very much...

that's what i've been trying to say all along...

get it now?

ndeniche 402 Posting Virtuoso Featured Poster

because it is modifying the first character of your string... why don't YOU understand?? in that case, the value in ptr is the address of the first character of the string, so, when you assign the pointer to that address a different character, you are changing the first letter of your string

ndeniche 402 Posting Virtuoso Featured Poster

first of all... i think it is very clear in the rules for posting that you shouldn't name your thread with names such as "help", or things like that...

second, think yourself as memory as a huge shelf,a pretty huge shelf, where you save information in bit sized boxes... when you create a pointer, you are telling the compiler to look for an empty shelf to start writing... when the compiler does this, information is stored in these shelves, so, your *ptr withdraws the information in your shelf...

in case of strings, your pointer will grab a group of shelves, which will store one character each, so, when you do this:

char *ptr="Literal String";

*ptr will return 'L', so... what happens when you tell the compiler to assign to *ptr another character (lets say 'd')? When you print your string, it should say "diteral String"

why? because your variable ptr is pointing to the first character in your string... you shouldn't manipulate a pointer to a string as it was stored in the same place in memory, because, what a pointer to a string does in memory is that takes the first "shelf" to store the first character, and then continues into other shelves...

get the idea?

ndeniche 402 Posting Virtuoso Featured Poster

actually i imagined something like that was going on... i knew that "\0" was still there...

i didn't know that for sure though... thnx...

ndeniche 402 Posting Virtuoso Featured Poster

if you can't prove that it's correct, it's horribly broken

I know it is horribly broken... actually, i wouldn't use it myself...

its just that i was in a desperate situation you know? i HAD to do it... i didn't find any other solution... :D

ndeniche 402 Posting Virtuoso Featured Poster

LOL
actually that worked for me once... that's why i recommended it ;)

ndeniche 402 Posting Virtuoso Featured Poster

First of all , it is a C program

darn... that was a close one... :P

Yes i know char accepts only single and wht u suggested Gel is exactly wht I tried but it did not work.

Why don't you try reading it as a string, even though it is a char? this should end with the buffer problem... this way:

scanf("%s",&answer);
ndeniche 402 Posting Virtuoso Featured Poster

Get DEV ! Why are you stuck with Turbo C++ ? BloodShed is problably one of the best compilers out there and compiles efficiantly.

it's not 4 me that i'm talking... as i've explained in others posts, i rather work in bloodshed's than in borland's, but, there's lots of peeps that must work in turbo because of work, college, university (like me), or other circumstances... so, i recommend you post solutions for users of any kind of compiler, because we all not have the privilege to work in our predilect compiler of c++...

ndeniche 402 Posting Virtuoso Featured Poster

If you need to using some timing functions to time your programs output then theres nothing more perfect than using windows sleep command.

The problem is, this command doesn't work on every program... i.e. Turbo C++ doesn't recognize this command...

ndeniche 402 Posting Virtuoso Featured Poster

nonetheless, i found out that clock() works different depending on which compiler you are working... 4 example... in dev c++, i measured clock measured 1/1000... but turbo c++ measured 1/20...

the thing is... i don't know why...

ndeniche 402 Posting Virtuoso Featured Poster

lol

come on... give me a break... where's the competition spirit?? haha (not that i would like to compete with you... i'm certain you would beat the hell out of me...)

ndeniche 402 Posting Virtuoso Featured Poster

I'd wager the OP is not using C++.

there's where i will not agree... I can bet the OP is using Turbo C++...That's exactly the same kind of code they were making me use when i started on Turbo... that's why i came out with that solution... (actually that's what i did when the buffer was filled up...)

ndeniche 402 Posting Virtuoso Featured Poster

actually, i would recommend to use cin and cout, but i assume you are being taught to work with scanf and printf, so i will provide a secondary solution, which i wouldn't recommend to an experienced programmer...

printf("Do you want to continue?(y or no)\n");
getchar();
 scanf("%c",&answer);

i works perfectly, as i said... but i wouldn't use it myself...

ndeniche 402 Posting Virtuoso Featured Poster

>which runs a WindowsXP OS....
It might start without crashing, but a lot of old programs start on Windows XP and don't work correctly due to their age.

I, as well, use Turbo (cause that's the one used @ the university [thing i don't actually like...]), and i installed it correctly and with no issues on two of my computers, which run, one Windows XP OS, and Windows Vista OS, and there's no problem for me using it... so i don't thing is the ancientness of the program...

are you sure you installed it correctly? have you tried installing it again?

You know, you could just say that you're being forced to use that compiler instead of being a jerk about it.

ooohh, yeah... i liked that... lol

ndeniche 402 Posting Virtuoso Featured Poster

o icic thanks um but what i was really wondering how does that work in the loop it kinda hard for me 2 picture it

i don't wanna be rude or whatever... but this is just the lamest way to waste our time...

you should want to read the book first... if that doesn't work, come to us... i can't imagine how a person that has read the book can come here to ask these questions... i mean... PLZ...

though, i will explain... any arithmetic operator will work EXACTLY THE SAME inside or outside any loop... so, y you have a "sum" variable created out of the loop and an assigned value of 0... (if you would have read the book, you would know...) "sum" would be your counter, or whatever you want to call it... so, what you have to do is

sum+=save

inside the loop just as Narue had pointed out several (many, indeed) threads ago...

It doesn't need a genius to figure that out...

ndeniche 402 Posting Virtuoso Featured Poster

this may require you to check your capital letters in a separate array...

my idea of a simple process to do this is the next one:

1.- create an array that includes all capital letters.

2.-inside a loop, compare all of the letters in the string to both arrays (capital and non-capital letters), and convert all letters in the string to non-capital letters, so that you won't have any trouble further...

3.- to make it trouble proof, compare all of the users inputs to both arrays in a loop, and convert all inputs into non-capital letters

4.- compare the input you just converted with the word you want the user to find...

ndeniche 402 Posting Virtuoso Featured Poster

whenever you wish to print or store code that is recognized as system code (meaning it will not be printed) such as quotes in a printf or cout, or things like that, you must include a "\" before the code... i.e.:

\"
\\
\%

etc...

ndeniche 402 Posting Virtuoso Featured Poster

when we recommended you to change the functions we told you, we meant you to change JUST THE LINES WE WERE TALKING ABOUT... instead, you changed the call 4 the function and the function prototype... which had nothing to do with what we recommended...;)

ndeniche 402 Posting Virtuoso Featured Poster

as suggested before, you shoul (in the main() function) assign your int small the value of the function findLowest, so, later, you can send it as a parameter to the function calcAverage... that should do it...

ndeniche 402 Posting Virtuoso Featured Poster

Another point:
Why are you declaring average in main() and then passing as an argument? Just declare it in calcAverage() only.

i agree with anupam_smart, but you can save even more memory by not declaring average at all... just do

cout<<(((score1+score2+score3+score4+score5)-small)/4);
ndeniche 402 Posting Virtuoso Featured Poster

well, it's pretty near to what i said, though that gave me an idea... why not make a fusion of both ideas and create two individual arrays with the size of the string: one with '_' in each element, and another one with the letters in the string in it. When the user's guess is correct, you enter a for loop and assign the user's guess letter into the matching places in array1 (the one with '_') and array2 (the one with the letters)...

get it?