Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Two dimensional array
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
versE91




PostPosted: Mon May 12, 2014 3:09 pm   Post subject: Two dimensional array

What is it you are trying to achieve?
The question asks you to make a two dimensional array program that puts 15 random integers from -5 to 20. When you run the program, it has to display the integers in 3 rows of 5 integers, get the sum of each row, get the sum of all the integers, input the integers squared, find the sum of all negative integers and find the smallest and largest part of the array.

What is the problem you are having?
Having trouble get the integers squared, finding the smallest and largest value and finding the sum of all the negative integers.


Describe what you have tried to solve this problem
For squaring the integers I tried to create new variable and tried to square the array.
For finding the smallest and largest value, I created a if statement with maxint and minint stating if the array is greater than 0 then it equals the maxint. If it's the opposite then it equals minint.
For finding the sum of the negative integer, I created an if statement saying that if the array is less than 0 then create a new variable adding all of the negative integers.
All them didn't work for some reason.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
attached with post

Turing:


attached with post



Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Mon May 12, 2014 4:53 pm   Post subject: Re: Two dimensional array

versE91 @ Mon May 12, 2014 3:09 pm wrote:
All them didn't work for some reason.


You need to tell us about what that reason was -- an error message, etc. You should also show us the code you tried, not just the working code.
versE91




PostPosted: Mon May 12, 2014 5:11 pm   Post subject: RE:Two dimensional array

Alright, I'll be back with updated version of the program.
versE91




PostPosted: Mon May 12, 2014 5:18 pm   Post subject: Re: Two dimensional array

here's the update
versE91




PostPosted: Mon May 12, 2014 5:20 pm   Post subject: RE:Two dimensional array

The errors I got were assigned value is the wrong type and column and intchart are not declared.
DemonWasp




PostPosted: Tue May 13, 2014 2:16 pm   Post subject: RE:Two dimensional array

Well, obviously you didn't declare 'column', because the if-statement isn't inside a for-loop.

It also complains because you try to add an array to an integer, which doesn't mean anything. You probably want to add a particular element of the array.

This same thing appears later when you try to assign an integer value to an array variable (rather than an element of the array).
versE91




PostPosted: Tue May 13, 2014 4:53 pm   Post subject: RE:Two dimensional array

Oh, I see. I think I know what to do from.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: