Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Generating random code using rand() function in mikroc

Status
Not open for further replies.

Mathi_theboss

Newbie level 5
Joined
Mar 28, 2013
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,351
How to generate 4 digit random code using rand() function in mikroc? can anybody help me...
 


Code C - [expand]
1
2
3
4
5
6
int result;
void main()
{
 result = rand();
 result = result/10;
}



- - - Updated - - -

rand()
Function returns a sequence of pseudo-random numbers between 0 and 32767.
So it is 5 digit sequence, dividing by 10 will work, hope so


Code C - [expand]
1
2
3
4
5
6
int result;
void main()
{
 result = rand();
 result = result/10;
}

 

Thank you guys... i got solution for this.

random_no=rand()%8999 + 1000;

The above code will generate random no of exactly 4 digits...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top