WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Think about it. Don't expect us to hand you all the answers. What loop makes sense?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Setting y to zero -- doesn't that guarantee the minimum is always 0, even though all the other inputs are > 0?

I'll give you a major clue here:

/* Obtain one input from user */
    printf("Enter a real number: ");
    input = scanf("%f", &x);
    maximum = x;       /* assume x is the biggest number */
    minimum = x;       /* assume x is the smallest number */

    printf("Enter another number: ");
    input = scanf("%f", &x);
    while (input != EOF)
    {
        maximum = max(x, maximum );    // test for a new maximum
    ....

See what you can still use of your loop.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Then you did it wrong.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

60-62

I see no definition of resultant.setNum(n); so maybe it doesn't do what you want it to do.

66-72

These lines output nothing but text then input 3 values.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Put the code in a loop.

As for the 12, you need to look up the srand() function.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Whether you have a good length or bad, you run the for loop outputting n characters of whatever happens to be in a

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sorry, I was asking for details, not concepts. What, when, where type of information. With 83 lines of code going all over the place, pinpoint the problem area.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I don't see a problem. Maybe you need to post some details about the "sometimes".

By the way, I would get rid of the while and change the if statements into while statements. Do all the seconds at once then move on to the minutes.

[edit]
Oh.
You always subtract 60 from the seconds. You did not put the statements in a block using { and }

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

On the other hand if i remove the do{ and }while(getnumber[o]!=' '); , the program works fine! It's just that I need this do loop there.

This is another one of those "what the heck" problems. If you remove the do-while and the code works fine, then you don't need the do-while .

Kinda like if you know how to get to your friend's house, you really don't need the GPS.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

All you is input one number.

You do not input one number at a time

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You haven't given us any direction what you need help with. We will not write the code for you, but with the lack of details you've given, that's all we can do.

Start by writing the code to input your value. If you can do that, we might be able to help further.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Can you try to give some details? Like where the problem is, what values are involved, what garbage characters. Without details we have no idea where to start since we didn't write the program.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please give a better description of the problem than "random numbers that are supposed to be generated will not cout"

That makes little sense.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

x = rand() % 30 for 0-29

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

for (j=2;j<8;j=j++)

Changing the variable from a to j does not change the fact the statement j=j++ is undefined.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please learn to format your code. If we can't follow it, it's very hard to help.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Ahh, using nonstandard I/O functions. Try it without getch()

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That works fine with Fbody's changes.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Actually, I am amazed about the large number of commercials from auto insurance carriers!

What amazes me is each and every company can save you hundreds by switching from one of the others. That basically means you sign up and the insurance company gives you a $300 check! Then you can switch again and get $700 from the new one. It's a really useful thing!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First thing is you have to try to make it a function. Then describe the problem you are having with it. We can then offer suggestions.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The statement a = a++; gives what is called undefined behavior because it is changing the variable a twice. Therefore the result may not be as expected.

Use either a = a+1; or a++; but not both.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
for (i=0;i<3;i++)
{
      for (j=2;j<8;j=j+2)
          {
                printf("value of a is %d, value of b is %d",i,j);
           }
 }

Gee, I thought the OP said

i want to write a program using "for" loop

You just screwed him over.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Try if (key == 27)

Has that worked for you? How?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What is __cdecl ?

(asking OP, not everyone)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@ firstPerson

thanks for your suggestion..
I did like this.. but in this way, every space is also counted as character and plays role in comparison whereas I would like to compare only words. e.g. if 3 words out of 5 are correct, it should reply correct.

----
Any more suggestions are welcome.

I assumed when you made the above comment about SPACEs, you corrected the code to ignore SPACEs. What other suggestions do you need?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You need to pass the size as well as the array. That's the only way the function knows how big the array is.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I guess he may be asking how to code something simmilar to

system("ls")

in VB .

Or he could be asking how to program a system like Linux. How can we tell?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Edit: Hey mods, can we write structured pseudo code? Or is that too much of a handout?

Sure. Write it kind of general so the posters still have to think some. I do pseudo code a lot.

Edit: I'm a noob.

Why does everyone say this? Don't you think we can't tell? And why should we care? Do you deserve special treatment because of it?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

here is my improved code still need help though.

You do? I don't see any description about what you need help with. Are we just supposed to guess?

.any advice is appreciated:

Always explain what you need, and why. Never leave it to us to guess. Mostly we guess wrong and it wastes both our times.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Your book doesn't mention how to get a single value from an array? I find that hard to believe.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Don't put it in the switch.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Keep track of the number of days per year. If you need March 12, that would be 31+28+12 (Jan+Feb+Mar). Now you can use your 7 days to get the days of the week. The % (mod) operator can help here.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I had that, already these are [ sqaures right? and these are { curley correct? Im using { in that code.

And what should you be using? What's you book say?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

or...

textunit.SelStart = Len(textunit.Text)

This is a much better solution...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Three loops.
Loop one -- prints a full line
Inside that loop is two loops:
Loop 1 prints the spaces before the '*'s
Loop 2 prints the '*'s

*? Im guessing you mean that Loop 1 prints the number, Loop 1 inside of Loop 1 prints the /n, and Loop 2 inside of Loop 1 prints..............what?

I am really curious? Is what you wrote actually what you think I wrote? Could you explain, please, how you translated my info? It makes no sense to me.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The book should show you examples, doesn't it?

Make a file called counter.h. Put the entire class definition in it. Erase the definition from the C++ code file. That's all there is to it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What would you like to change it to? What would be the purpose of it?

You only specify a header because you need to functions it references. You don't add headers because you like adding headers.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Three loops.
Loop one -- prints a full line
Inside that loop is two loops:
Loop 1 prints the spaces before the '*'s
Loop 2 prints the '*'s

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Eye found my kit on sail. How due ewe like it? Works good, does it knot?

Ezzaral commented: hehe +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

By learning Visual Basic well enough to write a system.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hello,

I am very new to C but need to use it to resolve a problem.

I have a variable called "W12".

All I want to do is increment W12 to W13, W14 etc and then use it later in my code (I am using QA Load to load test an application).

I am not sure if W12 is defined as a string, an array.

As I understand it you cannot mix integers and Characters in an array, I am sure this is quite simple to do but get bogged down in C tutorials about pointers and things when I try to code it my self (no previous experaince with writing C).

Can anyone help?

It all depends on what you are really asking.

No you cannot take a variable named W12 and increment it to a variable named W13.

Yes you can take a variable that contains "W12" and increment it to "W13"

But you need to know what you have as a variable definition.

I am not sure if W12 is defined as a string, an array.

For characters they are almost identical. The only difference is
string is an array of char with the last usable char set to '\0' or NULL
array is a sequence of char containing binary values. These binary values may be all ASCII characters or may be a mix. Depends on the purpose of the array.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you input more than one number, yes you can keep track. But you need at least two numbers to have a min and max.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please stop bolding your messages. If you look through these forum, you will not see messages in bold.

You start the loop just above the first line you need in the loop. That varies with every program. Usually above the initialization of values that must be set every time thru the loop, above a menu, that type of thing.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Copy the first letter to the new array
Start a loop (to copy letters)
    Start a Loop (to compare letters)
        Compare the current letter with all letters in the new array
    If not there, Copy it.
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You need to give better details than "strange numbers". What's your input? What's your output? What were you expecting? What part of the program do we need to look at?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I imagine that the "forum police" would agree with me.

We do. This thread almost got closed.

Clean up your attitude, faaz. You get more help by being thankful than being belligerent .

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Based on what I see:

/* Obtain two inputs from user */
        printf("Enter a real number: ");
        input = scanf("%f", &x);

                while (input != EOF)
                {

                        /* Invoke function to obtain max of both numbers */
                        maximum = max(x, y);

You accept x. Where do you read y? Don't you need two numbers to return the max or min?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Oops. I was mistaken....

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What is the value of x when you enter your while loop?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

There are about 15 non-empty lines in my text file before the blank lines and I am able to read everything in them properly. Once I reach the blank lines , both tmp1 and tmp2 are printed blank

Can anyone figure out what the problem is?

The problem is you read a blank line.

Blank lines are not automatically skipped when you read a file. If you want it skipped, you have to do the skipping with an if statement.