• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Official Homework Help & Discussions Thread.

curiousnathan

Starry-eyed
7,753
Posts
14
Years
Hold up -



It says that x produces a natural number when square rooted right? So wouldn't set C be {1, 4, 9, 16} since the set including the square roots of those numbers would be {1, 2, 3, 4} which are indeed natural numbers?

If C = {1, 4, 9, 16} and not {1, 5, 9} it might change your answer a little.

Yes! You're right, thanks for that.

So the final answer would be {1, 2, 4, 8, 9, 10, 14, 16, 20}, I'm pretty sure.
 

Alexander Nicholi

what do you know about computing?
5,500
Posts
14
Years
While I admit it's not homework, I would appreciate a little programming help with a chunk of code I'm working on, if you guys don't mind. It's C, specifically C99. *sneezes from dust*

Code:
for(pos = 0; pos <= length; pos++)
{
    
    // [truncated]
    
    
    
    // watch for comments
    #ifdef WINNT
    else if(config[pos] == ';')
    #endif
    #ifdef UNIX
    else if(config[pos] == '#')
    #endif
    {
        commenting = TRUE;
    }
    
    // skip over blank lines
    #ifdef WINNT
    else if(config[pos] == '\r' &&
    config[pos + 1] == '\n')
    #endif
    #ifdef UNIX
    else if(config[pos] == '\n')
    #endif
    {
        // ???
        continue;
    }
    
    // parse standard command names
    else if((config[pos] == 'S' || config[pos] == 's') &&
    (config[pos + 1] == 'T' || config[pos + 1] == 't') &&
    (config[pos + 2] == 'D' || config[pos + 2] == 'd') &&
    isctrlspacer(config[pos + 3]) == TRUE &&
    parsingcommand == TRUE)
    {
        // fill in later
    }
    
    // [truncated]
    
    else
    {
        configfile_error = TRUE;
    }
    
    continue;
}

As you can see here, I have a for loop that runs through a configuration file, doing what it will with the data contained. Albeit it's truncated for privacy reasons, towards the top are handlers for errors, and afterward comments - what I'm having an issue with is the else if block handling newlines in the middle there. The logic of the for loop is to have a single central location to break out of upon an error by setting a variable and continuing into the next iteration (soft breaks), but I'm not sure exactly how I'm supposed to handle the code for newlines. Obviously I want to skip into the next iteration and continue scanning the file, but I'm unsure whether an explicit continue is needed when there's a continue that it executes anyway after it iterates the conditional. How exactly is that supposed to be written? :v
 
20
Posts
9
Years
  • Age 31
  • Seen Jan 7, 2015
Name: Cream
Age: 22
Grade Level: Graduated college in May.
Specialty Subjects: French
Why do you want to be a PC Professor?: Well, I love tutoring French, and while I'm here I want to do something good for the community. Let me at those French students- I want to help!
 
3,830
Posts
14
Years
  • Age 27
  • OH
  • Seen Feb 26, 2024
While I admit it's not homework, I would appreciate a little programming help with a chunk of code I'm working on, if you guys don't mind. It's C, specifically C99. *sneezes from dust*

Code:
for(pos = 0; pos <= length; pos++)
{
    
    // [truncated]
    
    
    
    // watch for comments
    #ifdef WINNT
    else if(config[pos] == ';')
    #endif
    #ifdef UNIX
    else if(config[pos] == '#')
    #endif
    {
        commenting = TRUE;
    }
    
    // skip over blank lines
    #ifdef WINNT
    else if(config[pos] == '\r' &&
    config[pos + 1] == '\n')
    #endif
    #ifdef UNIX
    else if(config[pos] == '\n')
    #endif
    {
        // ???
        continue;
    }
    
    // parse standard command names
    else if((config[pos] == 'S' || config[pos] == 's') &&
    (config[pos + 1] == 'T' || config[pos + 1] == 't') &&
    (config[pos + 2] == 'D' || config[pos + 2] == 'd') &&
    isctrlspacer(config[pos + 3]) == TRUE &&
    parsingcommand == TRUE)
    {
        // fill in later
    }
    
    // [truncated]
    
    else
    {
        configfile_error = TRUE;
    }
    
    continue;
}

As you can see here, I have a for loop that runs through a configuration file, doing what it will with the data contained. Albeit it's truncated for privacy reasons, towards the top are handlers for errors, and afterward comments - what I'm having an issue with is the else if block handling newlines in the middle there. The logic of the for loop is to have a single central location to break out of upon an error by setting a variable and continuing into the next iteration (soft breaks), but I'm not sure exactly how I'm supposed to handle the code for newlines. Obviously I want to skip into the next iteration and continue scanning the file, but I'm unsure whether an explicit continue is needed when there's a continue that it executes anyway after it iterates the conditional. How exactly is that supposed to be written? :v

A rather late reply, but here:

The way I see it, it shouldn't really make a difference either way, right?
You'd only really need a continue there if you have code that is executed after that big if-else block that you want skipped.
Otherwise, it will act the same and you could just leave that little continue out.
 

Alexander Nicholi

what do you know about computing?
5,500
Posts
14
Years
A rather late reply, but here:

The way I see it, it shouldn't really make a difference either way, right?
You'd only really need a continue there if you have code that is executed after that big if-else block that you want skipped.
Otherwise, it will act the same and you could just leave that little continue out.
So would i just put empty braces there? Doesn't something have to be inside them, or am I mistaken?
 
17
Posts
9
Years
I know that there are a whole academy of professors on here already, but just in case.

Name: Sutpen
Age: 25
Subjects and Level: I have a BA in English and History, an MA in American Literature and Film and I am currently completing a PhD in American Literature, focusing on William Faulkner. Any questions regarding English (language or literature) or History (any country or century ) and I should be able to help.
 
Back
Top