29 Discussion / Question Topics

Remove Filter
Member Avatar for
Member Avatar for adrianrayce

Hello everyone, so i am basically new to C++ coding and i am trying to write the randNum function in a way that it will give me these ranges The range for this row is: 1 to 10: 5 4 10 2 7 9 1 8 9 6 The range …

Member Avatar for Avishek_1
0
314
Member Avatar for alon4963

How to set rand command, an integer from 3 to 50 (inclusive), but save it as a decimal number

Member Avatar for deceptikon
0
196
Member Avatar for mpc123

Hi im trying to random showing items from data base and when echoed the same ones appear? If anyone could help that would be great. This is the query SELECT * FROM TABLE1, TABLE2 WHERE FIND_IN_SET(TABLE2.FIELD1, TABLE1.FIELD1) and `FIELDNAME` >= RAND() LIMIT 10

Member Avatar for pritaeas
0
146
Member Avatar for lukas.vandendijssel

Hello, Somehow this is not working. I tried pretty much everything. I am also very new to PHP, but i made a nice CMS. Now I am making a website with some random flash-videos every time you refresh. This is what i got so far: <html> <head> <title>Sydcul.com</title> </head> <body> …

Member Avatar for bradly.spicer
0
313
Member Avatar for xxwikkixx

Hey everyone I was working on a small tool and also refreshing my programming skills. my problem is I want to pick a random number from 60,000 to 200,000. it does that but the number it displays are not dramaticly changed. For example if it out puts 062045, i hit …

Member Avatar for vijayan121
0
188
Member Avatar for LastMitch

Hi, I'm trying to preventing consecutive duplicate pages. For example when I refreshed a page it show a word from each page and when I refresh again it should show a different word from a different page not staying on one page. This is my pages: Page1 = Mozart Page2 …

Member Avatar for LastMitch
7
434
Member Avatar for nishad_forums

Hi, I have googled but found nothing about this. I am trying to generate a random number from a given array. But how do i do it? **Suppose:** I have an array `int arr[]={3,89,99,4,55};` and i want to generate a random number among these numbers. thanks in advance.

Member Avatar for nishad_forums
0
309
Member Avatar for arn2025

I have a list of about 500 names in a text file, i want to be able to get 5 random winners from this file. using C++ how do i do this

Member Avatar for Banfa
0
92
Member Avatar for NachoLobato

I have to create a game, in which the computer chooses randomly a word out of 5 and randomizes its characters, so that the user has to guess the word. He can also get a hint of the computer. I have started the code, but dont know how to continue: …

Member Avatar for Ancient Dragon
0
218
Member Avatar for moonw3ll

Just what is wrong with this simple code of mine? [CODE]#include<stdio.h> #include<string.h> #include<stdlib.h> main() { int i=0, num; char a[8]; char keyword[8]; system("cls"); while(i<8) { num = rand()%3; if ( num == 0 ) a[i] = 65 + rand()%26; /* 65 is the ascii value of A */ else if …

Member Avatar for moonw3ll
0
233
Member Avatar for coder_naive

I wrote this simple code in devc++. On compiling, the computer is showing syntax error at line int P = rand(); ... while the same line, if I write in the main function gets compiled easily. Please tell me what's going on! [CODE]#include <stdio.h> #include <stdlib.h> #include <math.h> struct poclick …

Member Avatar for coder_naive
0
156
Member Avatar for ineedsomehelp:3

Ok, I need to make a program that randomly generates 4 random letters from 12 random letter and it cannot reapeat the same letter. for example you can only pick from a,b,c,d,e,f,g,h,i,j,k,l and the program can randomly generate a,b,c,d or b,c,d,e but should not generate a,a,b,b or something that repeats.Another …

Member Avatar for ineedsomehelp:3
0
378
Member Avatar for jackmaverick1

Hi, I've been looking for a while for things that would give me random numbers under a value that I can specify (for me it's 5). I've seen [ICODE]rand();[/ICODE] and [ICODE]srand();[/ICODE]. I also know that[ICODE]srand()[/ICODE] is the seed and [ICODE]rand()[/ICODE] is the random number itself. Even the example programs don't …

Member Avatar for pseudorandom21
0
337
Member Avatar for benjybob

hi, i have a small problem with the rand operator. at first i tried using it without srand but gave me the same value each time. i have inserted srand(time(0)); but my compiler throws me up these errors: 1>c:\users\ben\documents\university work\year 2\c++\code\myc++\spritelab\asteroidsgame.cpp(17): error C4430: missing type specifier - int assumed. Note: …

Member Avatar for benjybob
0
417
Member Avatar for VP2

Hello! I've got a little problem... I want to make a program which puts 10 random character, but the characters should NOT be digits. [CODE]#include <ctime> #include <stdio> #include <iostream> using namespace std; int main() { time_t t; time(&t); srand(t); int i,c; char ch; printf("Generating 10 random characters...\n"); for(i=1;i<=10;i++) { …

Member Avatar for WaltP
0
150
Member Avatar for whit0851

Hello every one I'm trying to write a game that has a person guess a number between 1 and 100 hand have the computer guess that number via inputs from the user but I keep running into snags. [CODE]#include <iostream> #include <cmath> #include <cstdlib> using namespace std; int main() { …

Member Avatar for Crutoy
0
747
Member Avatar for surferxo3

[CODE] #include <iostream> #include <iomanip> #include <cstdlib> #include <ctime> using namespace std; int main () { int arr[9][9], n; srand(time(0)); for (int i=0; i<9; i++) { for (int j=0; j<9; j++) { n = rand() % 9; if (arr[i][j] == n) { n = rand() % 9; arr[i][j] = n; …

Member Avatar for surferxo3
0
143
Member Avatar for george61
Member Avatar for Dante2

Call me a noob, but is there a way to use [B][I][U]just[/U][/I][/B] PHP to create a photo slideshow? Or do you need to use flash? I have code that will display images in a random sequence, which is fine. [CODE=php]<?php $pic = rand(1,15); print "<img src=\"images/$pic.jpg\" height=\"100\" width=\"140\" />"; ?>[/CODE] …

Member Avatar for Dante2
0
189
Member Avatar for skorm909

Basically what I'm trying to do is simple. My main problem is the random numbers, but in the comments i have some other issues... if you know how to fix them that would be great the other two main ones im having trouble with are: the do loop until the …

Member Avatar for jonsca
0
143
Member Avatar for vavazoom

I'm trying to create a random float generator. The float must be 2 decimal places and between the values 0.50 and 999.99. I tried casting rand() to a float below, which didn't work. I'd still like to know the reason this didn't work. [CODE] saleAmount = ((float)rand() % 99950.00 + …

Member Avatar for vavazoom
0
270
Member Avatar for barevhayerable

Hello I have a > b(for example) I need to generate random number x that belongs from a to b for example a = 9, b = 16 x has to be x > 9 and x < 16 I use cstdlib.. but can't guess how to do it (using …

Member Avatar for arkoenig
0
339
Member Avatar for totalwar235

currently i am writing a text based RPG but, when i call for the fight my rand() either does not seed each time or it glitches to continuously gets the "Boar". if you could please take a look at it and see if the problem is in the coding, i …

Member Avatar for totalwar235
0
138
Member Avatar for TheBaby7591

This is the code I have so far. I can't even get the numbers range to print to the screen correctly. I am very new to all this stuff so go eacy on me. Can anyone help?? [code=c] #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> int main() { unsigned …

Member Avatar for TheBaby7591
0
110
Member Avatar for kirtan_thakkar

I am using the code as under but always getting 0 value means the same folder [code=php] $random_folder=array("folder1","folder2","folder3"); $folder=$random_folder[rand(0,count($random_folder)-1)]; [/code] Getting folder1 always.. What's wrong?? Please Help.......

Member Avatar for msm_eg
0
156
Member Avatar for james85

hi i would like u to tell me if i can make a random function to choose between four numbers and only them(-1 , 1 , -10 ,10)

Member Avatar for nbaztec
0
106
Member Avatar for naseerhaider

Hello Every one ! This program is producing some strange output as it is only generating x = 6 :(,can some through some light that why is it behaving like this ? [code] #include <iostream> #include <stdlib.h> using namespace std ; main () { // Random Number Program int num,x …

Member Avatar for naseerhaider
0
163
Member Avatar for tikoti

Hi all, I have tried to make a little example of a random number generator for c++. However, as I am quite new in this language I do not know its peculiarities. Here is the code [CODE] //g++ -o ran ran.cpp #include <iostream> using namespace std; int main () { …

Member Avatar for jephthah
0
467
Member Avatar for LloydFarrell

Hi, I have a bit of a strange problem where I am unable to "echo" results from a database - I will show you the code then explaine what im trying to do [code] <?php include_once "connect_to_mysql.php"; $sql = mysql_query("SELECT * FROM table ORDER BY RAND(), LIMIT 1"); while($row = …

Member Avatar for vaultdweller123
0
1K

The End.