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

lgbasallote Group Title

C array help

  • one year ago
  • one year ago

  • This Question is Closed
  1. lgbasallote Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    i have this code ``` #include <conio.h> #include <stdio.h> main() { int a[100]; int b, c, d; printf("How many numbers do you want? "); scanf("%d", &c); for (b=1; b<=c; b++) { printf("\nEnter number %d: ", b); scanf("%d", d); } getch(); } ``` how can i make the program print the inputted numbers in a form of a list?

    • one year ago
  2. thangeram Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    #include <conio.h> #include <stdio.h> main() { int a[100]; int b, c, d[c]; printf("How many numbers do you want? "); scanf("%d", &c); for (b=1; b<=c; b++) { printf("\nEnter number %d: ", b); scanf("%d", d[b]); } getch(); } may be this can be helpful

    • one year ago
  3. nidhie.raichura Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    #include <conio.h> #include <stdio.h> main() { int a[100]; int b, c; printf("How many numbers do you want? "); scanf("%d", &c); for (b=1; b<=c; b++) { printf("\nEnter number"); scanf("%d", &a[c]); } getch(); }

    • one year ago
  4. nidhie.raichura Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    The &a[c] lets you give an input of c numbers If you want to display it again then you can add up the following code for (b=1; b<=c; b++) { printf("\nThe numbers are\n"); printf("%d", a[c]); }

    • one year ago
  5. thangeram Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    it will give you array out of bound error ? dont you noticed?

    • one year ago
  6. Vellas Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    In C an array always starts at index 0, not 1. You can ask the user for the first number but the first position in the array is zero. And the highest index is the size of the array minus 1. 99 in this case. So you should use < instead of <= and starting at 0. Otherwise you could get an index out of range error when accessing index 100. #include <conio.h> #include <stdio.h> main() { int a[100]; int b = 0; int c = 0; // c mustn't be higher than 100 // if c is greater 100, ask the user again do { printf("How many numbers do you want (max. 100)? "); scanf("%d", &c); } while(c > 100); // input for (b=0; b<c; b++) { printf("Enter number %d: ", b+1); scanf("%d", a[b]); } // output for (b=0; b<c; b++) { printf("Number %d: %d\n", b+1, a[b]); } getch(); }

    • one year 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.