03-23-2020 07:24 AM
I got a task for classes and I have a huge problem with it.
Write a program that:
- It has two arrays of type int,
- Creates a third array, each element of which is the sum of elements of input arrays with the same index,
- if the calculated result is negative, add 5
Tip: use the case
I am just starting to learn in this programming environment and it is very difficult for me.
Would anyone be able to help me?
03-23-2020 07:32 AM
What have you tried so far? What did you learn in class about arrays? Have you read the material that was assigned? This is a pretty detailed, straight-forward problem. I'm not sure what "help" someone is going to be since doing your homework for you is not helping you.
03-23-2020 07:39 AM
What you are loking to do is very simple. You need to take some time and learn LabVIEW. Here are some links that will get you started:
http://www.ni.com/getting-started/labview-basics/
http://www.ni.com/academic/students/learn/
Good Luck
03-23-2020 07:42 AM - edited 03-23-2020 07:44 AM
Like johntrich said, this is quite well described as problems go.
Have you been able to create your two arrays and then add them?
Can you populate an array indicator with the sum of the first two, with the expected results?
03-23-2020 07:43 AM
I have big problem with case selector. When I join int to make it work at all, the program sums up what it takes but does not add 5 if the result is negative.
03-23-2020 07:45 AM
@wojtekmkr wrote:
I have big problem with case selector. When I join int to make it work at all, the program sums up what it takes but does not add 5 if the result is negative.
The probably intended solution likely involves a For loop and indexing tunnels.
03-23-2020 07:58 AM
A ternary operator in an expression node would eliminate the need for a for loop, a case structure, a selector, and boolean conversion.
"x<0 ? x+5: x"
Probably not the intent of the excersise though 😊.
03-23-2020 02:53 PM - edited 03-23-2020 02:57 PM
@wojtekmkr wrote:
Tip: use the case
Step 1: ignore "tips". 😄
Of course you won't be learning about case structures and loops and such, so don't submit that as solution! 😄
You can still use it to verify correct operation of your solution...
Step 2: Go over your class notes to see how to use a case structure correctly. 😉