Guessing Game In C
This is a small guessing game written in C.In this guessing game you have to guess a number between 0 & 100.You have 8 chances to do that.Every time you guess wrongly the program will give you a hint that your guess is too high or your guess is too low.Based on this hint you have to guess the number in the remaining attempts.Here’s the code
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main()
{
int num,guess=-1,tries=0,pass=0;
time_t t;
srand((unsigned)time(&t));
num=rand()%100;
while((guess!=num)&&tries<8)
{
printf(“Enter the guess num b/w 0 & 100 (you have %d tries left out)\n”,(8-tries)); scanf(“%d”,&guess);
tries++;
if(guess==num)
{
printf(“Hurray you guessed it correctly!!!\n”);
pass=1;
}
else if(num< guess)
printf(“Your guess is too high\n”);
else
printf(“Your guess is too low\n”);
}
if(pass==0)
printf(“Sorry you lost! The correct number is %d\n”,num);
}
Popularity: 2% [?]
By using/following this site you agree to our Legal Disclaimer


THis actually worked. I have been working on this project for a simple game program and could not figure out what i was doing wrong. I am using Miracle C compiler and thought it was the compiler but soem of the code ideas here helped me to identify my issues. Thanks
that’s good
yea but what about for complete beginners, im guessing past in ntoepad save as “blabla.c”? or .exe i have no idea?!? help me!
Leave your response!
EMAIL SECURITY »
How to Protect an Email Account from SPAM
Most of us get SPAM every day. Some of us get more and some little. Even a newly created email account will begin to receive spam just after a few days of it’s creation. Many times we …
NETWORK HACKS »
How to Find the IP Address of a Remote Computer
Most of you may be curious to know how to find the IP address of your friend’s computer or to find the IP address of the person with whom you are chatting in Yahoo messenger or Gtalk. …
PC SECURITY »
10 Tips for a Total Online Security
With the sudden rise in the Internet usage across the globe over the past few years, there has also been a rise in the amount of online scams and frauds. Today most of the Internet users are unaware …
VIRUS CREATION »
A Virus Program to Disable USB Ports
In this post I will show how to create a simple virus that disables/blocks the USB ports on the computer (PC). As usual I use my favorite C programming language to create this virus. Anyone with …
XP HACKS »
How to Hack Windows Administrator Password
This hack will show you how to reset Windows administrator password (for Win 2000, XP, Vista and Win 7) at times when you forget it or when you want to gain access to a computer …
Categories
Blogroll
Recent Comments
Most Commented
Most Popular
Log In | Entries (RSS) | Comments (RSS) | Sitemap | Arthemia Premium theme by Michael Jubel