Thread: Keep getting erron messege, not sure how to fix it!

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    6

    Unhappy Keep getting erron messege, not sure how to fix it!

    I am new to C++ and I am writing a program that will create 100 random numbers and split them by odd and even. I think I have the code correct but I keep getting this error:

    error C2440: '=' : cannot convert from 'void' to 'int'

    The error is for the line sum = srand(i)
    Here is the program:

    Code:
    #include <iostream>
    using namespace std;
    void main()
    {
    int i, num, even, odd;  
    
    for(i = 0; i < 100; i++)
    {
    num = srand(i);
    }
    
    if ( num % 2 == 0 )
    even = num;
    else;
    odd = num;
    }
    // main

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    duplicate post
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Keep getting erron messege, not sure how to fix it!
    By jessieo387 in forum C++ Programming
    Replies: 4
    Last Post: 03-20-2010, 06:48 PM
  2. Replies: 6
    Last Post: 12-06-2009, 06:09 AM
  3. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  4. C++ code need help to fix
    By McReal in forum C++ Programming
    Replies: 9
    Last Post: 05-12-2007, 02:48 PM
  5. Help me fix my mess!!!!
    By Starr in forum C++ Programming
    Replies: 35
    Last Post: 02-01-2006, 03:40 PM

Tags for this Thread