473,320 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

i did not run this program.then i want to know where are eror this code.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
int stime;
long ltime;
int thisRandomNumber;
int userinput;
int userTries;

/* get the current time and then send the random number */
ltime= time(NULL);
stime= (unsigned) ltime/2;
srand(stime);

//calculate a random number between 1 and 100 */
thisRandomNumber= rand() %100 + 1;

userTries=0;

do{
printf("Guess the random computer generated number:\n");
scanf("%d",&userinput);

if (userinput == thisRandomNumber){
printf("That's the number!\n");
}
else if (userinput > thisRandomNumber){
printf("Your guess is higher than the number.\n");
}
else if(userinput < thisRandomNumber){
printf("Your guess is lower than the number.\n");

userTries++;

}
while (thisRandomNumber!=userinput);

printf("\nCongratulations! That is the number! It took you %d tries", userTries);


return 0;
}
Jun 4 '14 #1
1 1171
weaknessforcats
9,208 Expert Mod 8TB
You have two basic errors.

Expand|Select|Wrap|Line Numbers
  1. ltime= time(NULL);
  2.  
ltime is a long whereas the time function returns a time_t.
The ltime needs to be a time_t.

The second error is your do-while loop. There is no while part.
Jun 4 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Prashanth Badabagni | last post by:
Hi , I'm Prashanth Badabagni .. I have and idea how a program prints it's own source code .. void main() { FILE *P; char *file,c; strcpy(file,__FILE__); p=fopen(file,"r");
4
by: louise raisbeck | last post by:
I have this scenario (simplified) function addnewdata () { check for partial match already in db for information entered by user if (partialmatch succeeds) { open new window aspx page (using...
0
by: smileman | last post by:
Hi In 5.0 Manual, I see XA Interface( use SQL,Connector/J ). But,
1
by: Sibasis Ganguly | last post by:
I want a vb code in access where if I open a database document from any where then it is not showing the security warning message bo and directly open the access form page.
4
by: Sibasis Ganguly | last post by:
I want a vb code by which ,when I open the database directly that created form will open , I don't want to click on form button then opening the form. If there is any code for my problem please...
1
by: reshmapk | last post by:
hello...i want a php code for my calander control.actually i want ...in my form having 'from' calander control and 'to' in 'from' calander.sapose i will click means that time i don't want privious...
5
by: stopka | last post by:
Hi, all. I create a program - I want to promote it and get some feadback from potential user. Where and how can I perform this? or index hd to search then. I do not sure is it possible to write...
0
by: tvnaidu | last post by:
Trying to open"Remote desktop connection", windows says"choose program you want to use to open this file". earlier it used to work, something happened, not sure something te deleted form my Windows...
4
by: Kyle Pellum | last post by:
I am trying to write a code to look through one column of a large worksheet pulling in data from that sheet in to others. What I have is a column titled "sector" I want the code to loop through this...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.