Random number generator. Even and odd numbers

I have a problem.
I have a random number generator, it goes from 0 to 20, I need to have two indicators, one will show how many numbers are pairs, and how many are not.
I tried to use the decimated 1D array, but since those numbers are random, it doesn´t work for me. I´m new with LabView, and I don´t know if there is some other way to make it work, I need some help, especially with some examples.
Thank you so much.
Solved!
Go to Solution.

RavensFan wrote:
Spoiler (Highlight to read)
Create the array.  Use quotient remainder to divide by 2.  Now you have an array where all the odd numbers are now 1, and all the even numbers are now 0.  Sum the array and you have the total number of odd numbers.  The number of evens will be the length of the array divided by the # of odds.
Create the array.  Use quotient remainder to divide by 2.  Now you have an array where all the odd numbers are now 1, and all the even numbers are now 0.  Sum the array and you have the total number of odd numbers.  The number of evens will be the length of the array divided by the # of odds.
Haha I lost sight of the fact that he was looking for the amount off odds and evens.  Good one.
Bill
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

Similar Messages

  • Add Even and Odd Numbers

    I have a programming assignment that needs to read a set of integers and then finds and prints the sum of the evens and sum of the odds.
    I know how to find out which numbers are odd and even, I just can't figure out how to add up the evens and odds. Say a set of 10 integers is inputted, how can they be added up after it is determined if they are even or odd?

    Here is my code after the tip from student... It compiles but once ran it doesn't do anything after the integers are put in.
    import java.util.*;
    public class EvenOddIntegers {
        static Scanner console = new Scanner(System.in);
        static final int limit = 10;
        public static void main(String[] args) {
             int number = 0, limit = 0, sumEven = 0, sumOdd = 0;
             int odds = 0;
            int evens = 0;
             System.out.print("Enter ten positive integers: ");
             while (limit <= 10)
                  number = console.nextInt();
             if (number % 2 == 0)
                  sumEven += number;
             else if (number % 2 != 0)
                  sumOdd += number;
             System.out.println("Sum of even numbers is " + sumEven + ".");
             System.out.println("Sum of odd numbers is " + sumOdd + ".");
    }

  • Detecting even and odd numbers

    Hi, I'm drawing a series of rectangles using AS3, and need
    every alternate one to be lighter... I'm using a switch statement
    currently, with a variable counting the number of rectangles and
    case 1, case 2, case 3, etc.
    Is there a formula or some way of telling whether there is an
    even or odd number of rectangles so my switch statement can just be
    case even:, case odd: ? The way I have it is fine for 10 or so
    rectangles but I'd rather make it more expandable.
    Would appreciate any suggestions

    % is a modulo operator that finds a remainder of a division.
    9%2 = 1, 9%4 = 1, but 9%3 = 0.
    In the case of odd/even numbers one can look at it as that an
    even number that leaves no remainder when divided by 2 and odd
    number is a number that leaves remaining 1 when divided by
    2.

  • Split and add Even and odd numbers

    Hi All,
    I got a seven digit number any number say for example (6581231). Now i need to add even number and odd number separately.
    Output should be
    6 + 8 + 2 = 16
    5 + 1 + 3 + 1 = 10
    Thanks
    S

    Assuming the number is always 7 digits one way to do this would be:
    Data: string(7) type c,
             num type i.
             Nmod type i.
    **move the number to a string.
    Move num to string.
    split into 7 individual chars.
    Num1 = string+1
    Num2 = string+2.
    Num3 = string+3
    Etc…
    divide each by 2 and find remainder
    Nmod = num  mod 2.
    if remainder is 0, number is even
    If nmod = 0.
    Number is even.
    Else.
    Number is odd.
    Endif.

  • How to display even and odd number ranges between two given inputs.

    Hi Every one,
    I am just started my career in sap abap and trying to find the solution for this.
    I am trying to display number range using select options, but I am getting an error "Memory low leave the transaction before taking a break".
    Example: when I give two number 2 and 10 , it should display set of all even and odd numbers in that range.
    Below is the code logic that I am using:
    data: a type i,
             b type i,
             c type i,
             d type i,
             num type i.
    select-options: in for num.
    a = inp-low.
    b=inp-high.
    c = inp-low mod 2.
    d = inp-high mod 2.
    while a <=b and c = 0.
    write: "even numbers:', a.
    b = a + 1.
    endwhile.
    while a <=b and c <> 0.
    write: "odd numbers:', b.
    b = a + 1.
    endwhile.
    Any help will be much appreciated.

    This is your logic...changed:
    data: a type i,
              b type i,
              c type i,
              d type i,
              num type i.
    data: even type i,
           odd  type i.
    select-options: in for num.
    a = in-low.
    b = in-high.
    c = a mod 2.
    if c is INITIAL. "It measn a is even
       even = a.
       odd  = a + 1.
    else.
       odd  = a.
       even = a + 1.
    endif.
    * Even
    a = even.
    while a <= b.
       write: / 'even numbers:', a.
    *  b = a + 1.
       a = a + 2. "The next even number
    endwhile.
    * Odd
    a = odd.
    while a <= b .
       write: / 'odd numbers:', a.
       a = a + 2. "The next odd number
    endwhile.

  • How to work even and odd number query

    Plz explain how below worked even and odd query
    2 ) why used subquery after from and which time we can use(what time of out put)
    even
    select * FROM (SELECT ROW_NUMBER() OVER(ORDER BY stud_id) as row ,grno,stud_id from stud_Enrollment) d
     WHERE d.row %2=0   
    odd
    select * FROM (SELECT ROW_NUMBER() OVER(ORDER BY stud_id) as row ,grno,stud_id from stud_Enrollment) d
     WHERE d.row %2=1

    Row_Number function returns the sequential number of a row
    (By using partition of a result set, starting at 1 for the first row in each partition)
    >> why used subquery after from and which time we can use(what time of out put)
    When we need sequntial numbers, we can use row_number function. Put it into derived table and use this derived table after FROM clause (Same way it is used in your query)
    CREATE TABLE stud_Enrollment (
    grno int,
    stud_id int,
    stud_name varchar(20)
    INSERT INTO stud_Enrollment
    VALUES (101, 511, 'Dheeraj'), (112, 521, 'Vaibhav'), (132, 522, 'Lalit'), (124, 564, 'Amogh'), (143, 598, 'Sushrut')
    SELECT * FROM stud_Enrollment
    -- Result of your table
    --grno stud_id stud_name
    --101 511 Dheeraj
    --112 521 Vaibhav
    --132 522 Lalit
    --124 564 Amogh
    --143 598 Sushrut
    -- Now we need to find out the rows which are at even position, ie row should be at position of 0,2,4,6,8 etc..
    -- But we don't have sequential number here in your table result
    -- So we can create one new column by using row_number function
    SELECT
    ROW_NUMBER() OVER (ORDER BY stud_id) AS row, --> additiona "row" column
    grno,
    stud_id,
    stud_name
    FROM stud_Enrollment
    -- We got "row" column in below output
    --row grno stud_id stud_name
    --1 101 511 Dheeraj
    --2 112 521 Vaibhav
    --3 132 522 Lalit
    --4 124 564 Amogh
    --5 143 598 Sushrut
    -- Now above table is used after FROM clause. It uses row column in WHERE part
    SELECT
    FROM (SELECT
    ROW_NUMBER() OVER (ORDER BY stud_id) AS row,
    grno,
    stud_id,
    stud_name
    FROM stud_Enrollment) d
    WHERE d.row % 2 = 0
    --row grno stud_id stud_name
    --2 112 521 Vaibhav
    --4 124 564 Amogh
    -Vaibhav Chaudhari

  • Does Labview have a Random Number Generator for U16 with a periodicity greater than 64 Million instances of U16words and one with SEED as the connector?

    We are doing some testing that requires 64MegaWords be written to our DSP memory  with random values to do a validity check and without repeating sequences with using the previous value as the seed for the next and us passing it the initial seed.  The dice one doesn't meet that criteria, and I was not sure how the continuous random number generator parameters work and if any of them would meet this criteria. Anyone have any information that might help?
    Thanks,
    Sue

    Hi suem,
    There is no reason why you couldn't simply write a pseudo-random number generator by yourself. Simply select a random number algorithm you want to use and implement it in LabVIEW. You do not need to interface code written in another language in order to implement a pseudorandom number generator. If you have a DAQ card or something, you can also use inputr noise or some other hardware soruce to generate real random numbers. For that also LabVIEW is an excellent tool.
    Tomi
    Tomi Maila

  • How to Build a VI that generates a random number between 1 and 80 ....Help!!!!

    Build a VI that generates a random number between 1 and 80 
    Divides the random number by a number specified in the front panel.
    If the inputted number is zero, the VI program should turn on a LED in the front-panel to indicate a divide by zero error.
    Solved!
    Go to Solution.

    One quick question Edward, was the answer just in time for your monday morning class.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Random Number between 10 and 30

    I'm just curious how to generate a random number between 10 and 30. I know I use the Math.Random function, but I'm not certain how to do it when the starting number is >1 (i.e. 1 to 30). Thanks.

    Random Number in an Interval:
    ((int) (randomGeneratedNumber * difference)) + startIndex + 1
    * randomGeneratedNumber - Number >= 0 and <1
    * difference: To generate between 10 and 30, (30 -10 = 20)
    * startIndex: In this example, 10
    * +1: Neccesary adjustment.
    Example:
    ((int)(randomGeneratedNumber * 20)) + 10 + 1
    PD. Int cast it's to generate int numbers, so it's optional.

  • Java random number generator

    Hi does java have a random number generator. If it does can you point me to it please. Thank you.

    you can use "java.Math.random()" this function returns a value which is greater than or equal
    to 0.0 and less than 1.It returns a double value,so you can multiply by 10 and cast it to int,so that it
    can produce numbers between 0 & 9.Yes, you can do that. But, as stated before, java.util.Random has methods that are easier to use for random int values than using java.Math.random is for random int values. It all depends what the OP wants. The OP hasn't come back with additional questions, or to say that he found his answer. So, we don't know whether he has his answer (he has several options now!) or not. :)

  • Help: JSP Random Number Generator

    hello every one,
    Im trying to generate a random number using currentTimeMillis(), in Jsp, can you help me out and advice me how can this be done please.

    First you say you want a random number, then you say you want a unique one. Which is it?
    Random numbers do not normally guaruntee uniqueness.
    is there away i could use the currentTimeMillis(), What would you use it for? System.currentTimeMillis() is commonly used as a seed for a random number generator. The java.util.Random class uses it like that - take a look at that API link.
    Or if its a homework question state the exact requirement - I'm guessing here.

  • Random NUMBER generator help..

    Hi all,
    i'm having issues with my random number generator i'm trying to fill my array with random numbers but i keep getting it filled with zeros.... can any one tell me what i'm doing wrong i can;t figure it out..
    for (int i =0; i < 100; i++){
                        int x=(int) (Math.random());
                        data[i] = x;
    }

    From the API "Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0."
    So casting the value to int is always going to result in a zero value.
    You need to multiply by a value that is one larger than the value you want to be your maximum. For example:
    int x = (int)(Math.random() * 100);
    should create a random number from 0 to 99

  • How do I create a random number generator?

    I know I've done it before...but I can't remember quite how to get it going. I'm creating a math tutor program, which generates two random numbers and asks the user to add them, and if the answer is right they get a message that gives props and if they get it wrong they're told they got it wrong.
    I can't get too far because I've forgotten how to make the number generator, so what exactly do you put in to get it?
    import java.util.*;
    public class AssignmentFour3 {
         private static Random integer = new Random();
         double number1 = 0;
         Random string1 = new Random();
         }

    DrClap wrote:
    Generally I don't write my own random number generator. I just use the java.util.Random class.I read it as though that that is what he was going to use, but wasn't able to read the API docs to figure out what methods to use. ;-)

  • Uniform random number generator

    anyone of u know how to generate UNIFORM RANDOM NUMBER GENERATOR that has serious faults ?

    jwenting wrote:
    uj_ is right (never thought I'd say that).
    ANYTHING "uniform" is by definition not random.Well, the correct term is "random numbers from a uniform distribution". And there certainly exist such generators (athough they're pseudo-random of course).
    I lost my temper because I've spent considerable time helping sosys only to realize he's a notorious cheater. Sosys claims to be a college student attending a CS class. With the knowledge, or rather lack thereof, he's displaying he must've cheated systematically for a long long time. I'm quite liberate at helping people with their homework but I won't help a leech become a programmer.

  • Anyone know how to select only even or odd numbered files in lightroom?

    Anyone know how to select only even or odd numbered files in lightroom? I need to reduce the quantity of images in my timelapse sequence and this would help me greatly since there are 8250 images and doing this maually would be tediuos and make me want to kill myself.... : )

    Do this.
    If they are jpegs, use .jpg instead of CR2
    Be sure to save this as a preset, as you WILL need it again. Mine is named "select even CR2", that is why it says that in the upper right.

Maybe you are looking for

  • Problem with file upload

    Hi all, my problem has something to do with internal working of pageflow. Here is what has happened: 1. I have a page with a few portlets on it. 2. One of the portlet is for uploading file (lets call it upload portlet) 3. The rest of the portlet need

  • How does full-text search for pdf files work?

    Hi there, Basically I can see my pdf file in the content server.. inside the pdf there's a piece of test that says: "Test's Sample" but when I do a search with that string the file gets filtered from the results. I think it has to do with the ' (sing

  • My 47 in 3d toshiba TV is stuck in 3d mode!!! HELP!!!

    Yes this is correct! My toshiba 3d tv all of a sudden got caught in 3d mode and will not let me change back to regualr tv mode! Its either in 2d or 3d mode and the remote will not let me change the pic size or anything! I have unplugged the tv and pl

  • I'm having trouble with the raise to speak feature for siri. Please help

    So I just got the Iphone 4s the other day and looked at a bunch of forums on how to use the raise to speak option but none of them have worked for me. I tried slowly raising it to my ear from a viewing position on the lock screen but it doesn't work.

  • Documentation on the BEx classes

    Hello All, is there some documentation on the BEx Excel classes (BExExcelApplication, BexItems, etc.). I have found some examples using this classes on SDN, but no complete documentation on them? Many thanks in advance, Kirill