Official Homework Help & Discussions Thread.

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.
 
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
 
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!
 
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.
 
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?
 
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