0

can u pls explain to me the use pf srand function & its syntax?i tried the following coding.it compiled,but runpage is not getting displayed.

#include<iostream.h>
#include<stdlib.h>
int randomno();
int main()
{    
 int i; 
   
 cout<<"ten random numbers for the range 0 to 50"<<endl;   
 for(i=0;i<10;i++)   
 {      randomno();     }   
return o;} 
int randomno()
{    int j;
    j = rand();     
 if (!(j >= 50&&j<=0))
   cout<< j<<endl; 
else
cout<<"out of range"<<endl;
return 0;
}
3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

one thing,
return 0 from main not 'o' (not o)
your code will work

try this

j = rand()%50;

and replace your condition

if (!(j >= 50&&j<=0))
cout<< j<<endl; 
else
cout<<"out of range"<<endl;

and only print the j
what is does ? requires minute mathematics.

0

why did you put a return in the middle of main() ? Lines 12-19 will never get executed because of that unconditional return on line 11. Just delete line 11 and the reset will be executed.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.