Simple last Selector Looser game by using "c".
Algorithm:-
1)Take i=21;
2) player 1 Enter the value among 1,2,3,4 as c1.
3) i=i-c1
4) Print remaining number after subtraction.
5) Player 2 enter the number among 1,2,3,4 as c2 but less than remaining after subtraction.
6) Repeated above process till i==0;
7) if process end after Player 1 selection then player 1 loose , else player2 loose.
CODE:-
#include <stdio.h>
int main()
{
int i=21;
int s1,s2;//r1,r2;
while(i>0)
{
printf("Player 1 Enter the number 1,2,3,4=");
scanf("%d",&s1);
// printf("Player 2 Enter the number 1,2,3,4=\n");
// scanf("%d",&s2);
if(s1>=1 && s1<=4)
{
i=i-s1;
if(i==0)
{
printf("\n Player 1 Loose. ");
break;
}
printf(" ********please enter the value less than %d******** \n",i);
}
else
{
printf("********please Enter the number 1,2,3 and 4.********\n");
}
printf("Player 2 Enter the number 1,2,3,4=");
scanf("%d",&s2);
if(s2>=1 && s2<=4)
{
i=i-s2;
if(i==0)
{
printf("\n Player 2 Loose.");
break;
}
printf("******** please enter the value less than %d********\n ",i);
}
else
{
printf("********please Enter the number 1,2,3 and 4.********\n");
}
// if(r1==0 || r2==0)
//i==0;
}
return 0;
}
Comments
Post a Comment