• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Beginner Array Help

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Having trouble realizing a problem I'm having with my Arrays.
End result is suppose to display Team Name, and Team Members, from user input any help is appreciated, thanks!
 
Bartender
Posts: 1464
32
Netbeans IDE C++ Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the ranch, Rodshaun. I've added codetags to your post, which makes the code a lot easier to read. Have a look and be sure to UseCodeTags whenever you can.
 
Rancher
Posts: 1059
27
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

NUM_TEAMS is not declared so code does not complile

This for loop opens the scope using the variable x as a single statement (but you have a block defined in the next statement so it goes on more than 1 line)

this for loop opens the scope using the variable y for a block defined by {}

Here you open another scope using the variable x without closing the previous scope, so your x variable is being double tasked and expectations may not be realized for your original scope using x

closes your second scope using x

closes your scope using y and allows your first scope using x to close


So basically your undefinded NUM_TEAMS and the double use of the variable x is causing your problems in your overlapping scopes.
 
Les Morgan
Rancher
Posts: 1059
27
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You basically have this, and are achieving very similar results:
 
Rodshaun Bottoms
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it to work much appreciated!
 
Yeast devil! Back to the oven that baked you! And take this tiny ad too:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic