C Code 17 _ C Program for Lucky Prize draw
Program:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int
ch,luck,you,i,lucky,id;
srand(time(0));
printf("\n*
* * * Guess and Win * * * *");
printf("\n\nRules
of the game : ");
printf("\nYou
have three chances to win a prize");
printf("\nGuess
any number from 1 to 20");
printf("\nIf
your number is same as lucky number you will win");
printf("\n\nEnter
1 to start and 2 to exit");
printf("\n\nYour
choice : ");
scanf("%d",&ch);
if(ch==1)
{
printf("\n\n* * * * * * Lets start the
treasure hunt * * * * * *");
for(i=1;i<=3;i++)
{
luck=rand()
% 20 + 1;
printf("\n\nEnter your number (Try
%d): ",i);
scanf("%d",&you);
printf("\n\nYour number : %d \t LucK
Number : %d ",you,luck);
if(you>20||you<1)
{
printf("\n\nEnter
numbers only from 1 t0 10");
i=i-1;
}
else
{
if(you==luck)
{
lucky=rand()
% 5 + 1;
id
= rand() % 132451 + 123454;
if(lucky==1)
{
printf("\n\nCongrats
!!! you won a Audi Q3 car ( prize id : %d ).... send your details along with
the prize id to the following mail id (jebasinghp43@gmail.com)",id);
break;
}
if(lucky==2)
{
printf("\n\nCongrats
!!! you won a Apple iphone 10 ( prize id : %d ).... send your details along
with the prize id to the following mail id (jebasinghp43@gmail.com)",id);
break;
}
if(lucky==3)
{
printf("\n\nCongrats
!!! you won a Google pixel 3 ( prize id : %d ).... send your details along with
the prize id to the following mail id (jebasinghp43@gmail.com)",id);
break;
}
if(lucky==4)
{
printf("\n\nCongrats
!!! you won a Macbook Air ( prize id : %d ).... send your details along with
the prize id to the following mail id (jebasinghp43@gmail.com)",id);
break;
}
if(lucky==5)
{
printf("\n\nCongrats
!!! you won a Tour to England ( prize id : %d ).... send your details along
with the prize id to the following mail id (jebasinghp43@gmail.com)",id);
break;
}
}
else
{
if(i==1)
{
printf("\n\noops
!!! you have 2 chances left");
}
if(i==2)
{
printf("\n\noops
!!! you have 1 chance left");
}
if(i==3)
{
printf("\n\n
* * * Better Luck Next Time * * * ");
}
}
}
}
}
else
{
exit(0);
}
getch();
return
0;
}
Output:
Thank You ...
0 comments: