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

What do the numbers tell me, in terms of frequency, amplitude and maybe time?

Thank you muchly!
drue

Pretty much everything.

If you are really asking "What is the format of a file", you'll have to search the web for for a definition of the file format.

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

Maybe you should reread what Gerard said. He's onto something.

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

First of all, you read two numbers and never read any more.

Try this:
Read the first number. Set min and max to this number. This seeds the min/max with at least one number actually in the list.
Set up a loop to read the rest of the numbers one at a time and test for min and max.

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

Hah, I did not =(. But I think my solution would have worked well though!

I beg to differ.... Look carefully at the question...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
random_integer = rand()%10;
for(int i = 0;i< index ; i++)
{
    if(num[i] == random_integer){    // Why are replacing a good number with a new number?
        random_integer = rand()%10;  // How do you know the new number isn't the same as the old number?
        num[i] = random_integer ;    // and what are the initial values of num when you start? (don't assume, check it out)
    }
    
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{

	int x; 
	int y; 
	int i;
	int c;
        int primecount;
        int average = average + ;

	printf( "Enter two positive integers --> " );
	scanf("%d%d" , &x, &y );

	while (y >= x ) 
	{ 
		c=0;
		printf ( "\n    %d:\t" , x ); 
		for(i=2;i<x;i++)
			if(x%i==0)
			{ 
				printf("  %d ",i);
				c++;
			}
/** the following code should be outside the FOR loop.  
    You are testing one number (2) and printing "Prime" 
    if x%2 != 0.  Then you increment x AND primecount
    no matter what. 
    Next time through the loop you are testing x+1 with 3,
    then x+2 with 4, and so on.... **/

			if (c==0)
				printf("Prime");
			x++;
                        primecount++
                        printf( "\nThere are %d Prime numbers.\n", primecount );
                        printf( "The average of the prime numbers is %.2f\n", average );
                        printf( "Enter two positive integers --> " );
	                scanf("%d%d" , &x, &y );
			
	}
	return 0;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague


Can i further improve it in any way?

Thanks.

Yes. See the comments I added:

void trimString()
{
	char s1[] = "hello world";
	char s2[] = "el";
	int i, j;

	/* Do not use strlen() as a loop parameter.  
	   Use it to load a variable before the loop and use 
	   the variable in the loop definition */
	/* Why are you casting the value to signed? Define the loop 
	   parameter variables as unsigned if you think it's necessary */
	for (i = 0; i < (signed)strlen(s1); i++) {
		for (j = 0; j < (signed)strlen(s2); j++) {
			if (s1[i] == s2[j]) {
				s1[i] = -1;   // this is good
				break;
			}
		}
	}
	for (i = 0, j = 0; i < (signed)strlen(s1); i++) {
		if (s1[i] != -1) {
			s1[j] = s1[i];
			j++;
		}
	}
	s1[j] = '\0';
	printf("\nString is%s", s1);
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

hi,

Is it possible to load a c file into another c file? I want to give a list of functions used in the c file.

Sure. Open the C file with your new program and read the file a line at a time, looking for the function names. You have to weed out all the reserved words first (while, if, break, etc). Then you have to look at what's left to see if it's a function name or a variable.

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

Where did you call strReverse() ?
Where did you call palindromeCheck() ?
Where does equal get set to T or F?

You have to actually try calling them, they don't just run automagically...

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

I posted my code an hour ago too so how do you know what I have changed and what not.

Then why are you asking for more help if you aren't telling us the current state of the program? Aren't you asking us to shoot a moving target -- while blindfolded?

Listen to the Dragon. He's trying to help using the definition of the problem as you stated it. super-sonic is changing the definition of the problem because he does not understand or didn't read your requirements.

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

Please stop using cutsey text. Beginning letters of sentences are in upper case, the rest in lower case, as per English Writing Style.

Yes we have the code. Can you have it? No. We do not give code for the purposes of cheating. It's your class, not ours.

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

Look at the getlin() method.

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

This is the main part of a project
I assume all other header and cpp file are correct
cuz most of them are copy from books n the professor

Bad assumption. Check them to make sure they are correct.
And n is not a word. Be sure to reread the member rules, especially about being clear.

when I run it, "right after the input"
the program sort of stopped,

Sort of stopped? Are we supposed to understand what that means?

pop out a error message,

The error it "popped out" wasn't important enough to tell us, should we guess?

then keep running
n crashed after my test part of printing out the "queue"

Stopped, error, kept running, then crashed? Weird...

so I assume there got to be a error for input?!
n maybe when translating from prefix to postfix?

Could be anything. Try pinpointing exactly where the crash happens.

please anyone, help me out by simply point out my error(or maybe it isn't that simple)
I wish to learn from my own error, n help out someone else someday

Try explaining in detail what is happening. We sort of can't tell with sort of explanations.

Add output statements to see if the correct stuff is happening at the correct times, like the input was read correctly.

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

cin.ignore has absolutely nothing to do with cout. Nothing. It has to do with cin.
When you input a number using cin, you hit a RETURN to allow the number to be read. But the RETURN is left in the input buffer to be read on the next input -- like getline(). That RETURN is now read and the getline() continues as defined. That's why the cin.ignore is used.

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

Since you didn't bother formatting your code, it's hard to follow. My guess is you're outputting your \n at the wrong time.

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

Well, the 61 characters you are reading into first, last, and middle are being loaded into the 30 character array student_file (do you see a problem there?)

Then next read loads the next name into the 30 character array student_file (what happened to the previous name loaded?)

Also, are you sure first, last, and middle get the data you read correctly? You might want to print them out to verify it.

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

srand() should be called once and only once at the beginning of your program. Move it into main()

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

It is a good practice to not use the system("pause"), the reason is that this will only work on a windows, and if you take it to another computer it won't work. Try using a fflush(stdin); followed by cin.get();

It's also a bad practice to use fflush(stdin) because it's a legal operation -- you cannot flush an input buffer.

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

Maybe getline() would be helpful...

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

I have a problem. I got my file to open but I don't know how to modify the file and have the output I need.

Well, the first thing you have to add is reading the file input.txt.

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

Set up a while loop and exit if number < 10. If not <10, add the digits.

You have to try writing something to get more detailed help...

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

Read the input as a string and check that each character entered fits the base you want.

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

If you do that, Word won't be able to read the document.

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

So move the initialization code where you need it to be.

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

Considering Nathan showed you how, I suppose no one deemed it necessary to respond...

NathanOliver commented: thanks +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Define "goes nuts". That is hard to imagine.

Explaining a problem correctly often results in more accurate answers and better help.

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

and I assume that involves malloc or calloc, where is a good site to relearn those key concepts again?

No, it involves creating space: char answer[20]; Also, see this series on scanf(). You are using it dangerously.

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

I don't see a loop... I see a question. Read the member rules -- especially the Keep it Clear section.

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

Use an array for the 4 cards. Get a random number from 0-3. This will be an index into that array to point to the win card.

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

Not to rain on your picnic table, but of what real use is yet another site that has recipes that are already posted on a dozen other sites already?

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

Also, how do you know when you've reached the end of a list?

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

Read the documentation for "The unix utility application that strips the HTML markup tags from the file’s content leaving just content text"

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

1) Assuming you need to "access each number one at a time", put the program in a loop. Inside the loop, read a number, use it, then when the loop returns to the beginning, the next number will be read.

2) If you need to use multiple numbers at the same time, the only appropriate way is to use an array. But from your description, this is not your case.

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

Use getche() in place of scanf. why scanf is not working, answer of this question
is here

http://www.gidnetwork.com/b-59.html

repz=getch(); 
or 
repz=getche();//echo the character on screen

Best Of Luck

Yeah, Best of Luck. Since getche() is a non-standard function, it's use is suspect and not recommended. It has been defined in only a couple of the hundreds of compilers created.

And I already told him where the answer is :icon_wink:

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

One way is after you read the line, read each word of the line within a loop using sscanf() .

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

Read your input as a string. Then test the characters for valid digits. If good, convert to integer. If not...

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

You cannot input into the string "\t".

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

Read this series on scanf(). It should answer your questions.

N1GHTS commented: I admire your simple yet effective method of solving problems. +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Did you create a MAIN function in your code?

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

Look into loops. FOR and WHILE loops will help you get started. You did read the member rules, right?

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

When you read "::::::::" you know the next line is a name, followed by another "::::::::". Then read the data up to the blank line or "::::::::" saving each line in an array. Then look through the array for your keyword.

Continue by reading the next name information.

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

No, it's because of this

tux4life commented: Yes. +8
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I get that part and what I will do if a wrong number is entered.

A contraire. As the rules state, "Do provide evidence of having done some work yourself if posting questions from schoolwork assignments". I see no evidence.

What I don't know is how many variables I should declare or what commands I should use.

This completely depends on what algorithm you decide to implement.

Sit at your desk with pen and paper. Write down two binary numbers. Add them. Now think about what you just did and write down each step you performed in excruciating detail.

There is your algorithm. Convert it to code.

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

Start by asking for the binary number. Then check the number for illegal characters.

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

Think about it. What's your format specifier? What is being replaced in the format specifier? What is it being replaced with?

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

Isn't it exactly the same for this forum as all other forums? If so, how could you post here? If not, what's different?

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

Could the bullets on the rules be changed to numbers? That way we can reference exactly which rule was violated.


In SPAM-FREE:
Do not mention, plug or refer to any product, service, or website you are affiliated with anywhere outside of Business Exchange forums which are specifically designated for this purpose
Would the above bold make this clearer? Or is there something else to make the last part less confusing?

In PLEASANT, "DaniWeb inappropriate language filter" is a thing and should probably be in italics or quotes.

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

What makes you think so?

200 * .09 = 18
18 + 200 = 218

Exactly what was printed.

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

Your second input for Letter Grade wants to input into number (a float) rather than a character.

And what values do you expect to get with Sum += LetterGrade; when Sum is a float and LetterGrade is a character?

Second: put the switch statement inside the loop, with all the code needed to process each input.

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

That's the correct solution.