29 Discussion / Question Topics
Remove Filter
|
|
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 … |
|
How to set rand command, an integer from 3 to 50 (inclusive), but save it as a decimal number |
|
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 |
|
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> … |
|
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 … |
|
|
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 … |
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. |
|
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 |
|
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: … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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: … |
|
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++) { … |
|
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() { … |
|
[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; … |
|
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] … |
|
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 … |
|
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 + … |
|
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 … |
|
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 … |
|
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 … |
|
|
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....... |
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) |
|
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 … |
|
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 () { … |
|
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 = … |
The End.