Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

alfers101

what is the meaning of: i=-n in here: for(i=-NUM; i<=NUM; i++)

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. ecdown
    Best Response
    You've already chosen the best response.
    Medals 6

    This will make i equal to the negative of NUM. So if NUM = 3, the for loop will loop between -3 -2 -1 0 1 2 and finish with i = 3 after the for loop.

    • 2 years ago
  2. alfers101
    Best Response
    You've already chosen the best response.
    Medals 0

    how about this one? what is the meaning of this: if( abs(i)+abs(j)<=NUM)

    • 2 years ago
  3. Toolan
    Best Response
    You've already chosen the best response.
    Medals 1

    abs means absolute. It basically ignores the minus sign if it exists, so abs(-10) would be 10. abs(i)+abs(j) means take the value that's in i, strip off the minus sign and add it to the value in j without it's minus sign. <= means less than or equal to, so the whole thing means: if the sum of i and j (ignoring minus signs) is less than or equal to the value in NUM, then... do the next statement (whatever that is).

    • 2 years ago
  4. alfers101
    Best Response
    You've already chosen the best response.
    Medals 0

    can u show me a code that can make a output showing a square with a hole. when i enter 2 number for row and column. for example i enter n(column)=5, m(row)=3: ***** * * *****

    • 2 years ago
  5. ecdown
    Best Response
    You've already chosen the best response.
    Medals 6

    Here is a piece of code that will print the box of stars. #include<stdio.h> int main(int argc,char **argv) { int column; int row; int x; if (argc < 3) { printf("Not enough arguments\n"); return 1; } column = atoi(argv[1]); row = atoi(argv[2]); if (row < 2) { printf("not enough rows\n"); return 1; } printheaderfooter(column); for(x=1;x < row -1; x++) { printcontent(column); } printheaderfooter(column); printf("%d %d", column,row); } void printheaderfooter(int length) { int i; for(i=0;i<length;i++) { printf("*"); } printf("\n"); } void printcontent(int length) { int i; printf("*"); for(i=0;i<length - 2;i++) { printf(" "); } printf("*\n"); }

    • 2 years ago
  6. alfers101
    Best Response
    You've already chosen the best response.
    Medals 0

    wow ?! can u do it using for loop? im not yet familiar with the other loops

    • 2 years ago
  7. alfers101
    Best Response
    You've already chosen the best response.
    Medals 0

    can u show me a code. printing a pyramid ? for example, i type 5. this would be the output: * ** *** **** ***** using c++

    • 2 years ago
  8. ecdown
    Best Response
    You've already chosen the best response.
    Medals 6

    The previous example used for loops in function calls, if you want direct code then you can I can restructure the code to use just the main function. Pyramid example: #include <iostream> using namespace std; int main() { int count; cin >> count; for(int i = 1; i <= count ; i++) { for (int j = 1; j <= i; j++) { cout << "*" ; } cout << endl; } return 0; }

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.