#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
int random;
int userguess;
int noofguess=0;
int k;
int i;
printf("\t\tThis is simple guessing game\n");
printf("\t\tI am thinking numberin between 1 and 100\n");
printf("\t\tYou have to guess correct number\n");
printf("\t\tHere are some hints for you\n");
printf("\t\tYour game starts now\n");
printf("\t\tHAPPY GUESSING\n");
random=rand()%100+1;
{
int i;
printf("->Factors are: \n");
for(i=1;i<=random;i++)
{
if(random%i==0)
printf("%d \n",i);
}
{
int count=0,i;
for(i=1;i<random-i;i++)
{
if(random%i==0)
count++;
}
if(count==2)
printf("->It is Prime number\n");
else
printf("->It is Composite number\n");
}
{
if(random%2==0)
printf("->it is even number\n");
else
printf("->it is odd nnumber\n");
}
{
int temp,reverse=10;
temp=random;
while(temp!=0)
{
reverse=reverse*10;
reverse=reverse+temp%10;
temp=temp/10;
}
if(random==reverse)
printf("->It is palindrome\n");
else
printf("->It is not a palindrome\n");
}
do
{
printf("*enter number in between 1 to 100*\n");
scanf("%d",&userguess);
noofguess++;
if(userguess>random)
printf("%d is greater than what I am thinking\n",userguess);
if(userguess<random)
printf("%d is less than what I am thinking\n",userguess);
}
while(random!=userguess);
printf("congrats you have guessed the no.\n");
printf("total guesses = %d ",noofguess);
getch();
return 0;
}
}
#include<conio.h>
#include<stdlib.h>
int main()
{
int random;
int userguess;
int noofguess=0;
int k;
int i;
printf("\t\tThis is simple guessing game\n");
printf("\t\tI am thinking numberin between 1 and 100\n");
printf("\t\tYou have to guess correct number\n");
printf("\t\tHere are some hints for you\n");
printf("\t\tYour game starts now\n");
printf("\t\tHAPPY GUESSING\n");
random=rand()%100+1;
{
int i;
printf("->Factors are: \n");
for(i=1;i<=random;i++)
{
if(random%i==0)
printf("%d \n",i);
}
{
int count=0,i;
for(i=1;i<random-i;i++)
{
if(random%i==0)
count++;
}
if(count==2)
printf("->It is Prime number\n");
else
printf("->It is Composite number\n");
}
{
if(random%2==0)
printf("->it is even number\n");
else
printf("->it is odd nnumber\n");
}
{
int temp,reverse=10;
temp=random;
while(temp!=0)
{
reverse=reverse*10;
reverse=reverse+temp%10;
temp=temp/10;
}
if(random==reverse)
printf("->It is palindrome\n");
else
printf("->It is not a palindrome\n");
}
do
{
printf("*enter number in between 1 to 100*\n");
scanf("%d",&userguess);
noofguess++;
if(userguess>random)
printf("%d is greater than what I am thinking\n",userguess);
if(userguess<random)
printf("%d is less than what I am thinking\n",userguess);
}
while(random!=userguess);
printf("congrats you have guessed the no.\n");
printf("total guesses = %d ",noofguess);
getch();
return 0;
}
}
No comments:
Post a Comment