content
2 code for love
3 rock paper ✂
1.Guess the number
code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
int main()
{
int number, badluck = 0;
int guess, count, level, players;
int retry = 0;
char name1[20], name2[20];
srand(time(0));
printf("\n--------------------------------------------------------\n\nThis is a number guessing game\nWe have generated a random number you have to guess it\n\n\nChoose level --(ans in 1,2,3)--\nEASY-->(1)\nNORMAL-->(2)\nHARD-->(3)\n", level);
scanf("%d", &level);
printf("\n--PLAYERS--\nSingle Player-->(1)\n");
scanf("%d", &players);
if (players == 1)
{
printf("Type your name here :");
scanf("%s", &name1);
// printf("%s ", name1);
}
if (level == 1)
{
number = rand() % 50 + 1;
do
{
printf("\n %s your number is between 1-50\n\n TYPE YOUR GUESS ->", name1);
scanf("%d", &guess);
if (guess == number)
{
if (badluck <= 0)
{
printf("\n\n**********************************************\nYou Performed Amazing \n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 1)
{
printf("\n\n**********************************************\n\n\nYou did very well (;\n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 3)
{
printf("\n\n**********************************************\n\n\nYou did average\n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 6)
{
printf("\n\n**********************************************\n\n\nYou did good \n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 8)
{
printf("\n\n**********************************************\n\n\nBetter luck next time \n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else
{
printf("\n\n**********************************************\n\n\nTry try but don't cry\n\n you did in %d try\n\n**********************************************\n", badluck);
break;
}
}
else if (guess < number)
{
count++;
badluck++;
printf("\n@@ ~~ Enter Greater number ~~ \n ");
if (count == 15)
{
printf("\nretry number is:%d,\n and level is :%d\n\nRETRY -->(0)\nEXIT--(1)\n", count, level);
scanf("%d", &retry);
}
}
else if (guess > number)
{
badluck++;
count++;
printf("\n@@ ~~ Enter Small number ~~ \n");
if (count == 105)
{
printf("\nretry number is:%d,\n and level is :%d\n\n\nRETRY -->(0)\nEXIT--(1)\n", count, level);
scanf("%d", &retry);
}
}
else
{
printf("what are you typing bro +_+");
}
} while (count < 112);
}
if (level == 2)
{
number = rand() % 100 + 1;
do
{
printf("\n%s your number is between 1-100\n\n TYPE YOUR GUESS ->", name1);
scanf("%d", &guess);
if (guess == number)
{
if (badluck <= 0)
{
printf("\n\n**********************************************\nYou Performed Amazing \n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 1)
{
printf("\n\n**********************************************\n\n\nYou did very well (;\n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 3)
{
printf("\n\n**********************************************\n\n\nYou did average\n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 6)
{
printf("\n\n**********************************************\n\n\nYou did good \n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 8)
{
printf("\n\n**********************************************\n\n\nBetter luck next time \n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else
{
printf("\n\n**********************************************\n\n\nTry try but don't cry\n\n you did in %d try\n\n**********************************************\n", badluck);
break;
}
}
else if (guess < number)
{
count++;
badluck++;
printf("\n@@ ~~ Enter Greater number ~~ \n ");
// \n\nRETRY-- > (1)\nEXIT--(0)\n
if (count == 105)
{
printf("\nretry number is:%d,\n and level is :%d\n\nRETRY -->(0)\nEXIT--(1)\n", count, level);
scanf("%d", &retry);
}
}
else if (guess > number)
{
badluck++;
count++;
printf("\n@@ ~~ Enter Small number ~~ \n");
if (count == 15)
{
printf("\nretry number is:%d,\n and level is :%d\n\n\nRETRY -->(0)\nEXIT--(1)\n", count, level);
scanf("%d", &retry);
}
}
else
{
printf("what are you typing bro +_+");
}
} while (count < 112);
}
if (level == 3)
{
number = rand() % 200 + 1;
do
{
printf("\n %s your number is between 1-200\n\n TYPE YOUR GUESS ->", name1);
scanf("%d", &guess);
if (guess == number)
{
if (badluck <= 0)
{
printf("\n\n**********************************************\nYou Performed Amazing \n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 1)
{
printf("\n\n**********************************************\n\n\nYou did very well (;\n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 3)
{
printf("\n\n**********************************************\n\n\nYou did average\n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 6)
{
printf("\n\n**********************************************\n\n\nYou did good \n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else if (badluck <= 8)
{
printf("\n\n**********************************************\n\n\nBetter luck next time \n\nyou done this in %d try\n\n**********************************************\n", badluck);
break;
}
else
{
printf("\n\n**********************************************\n\n\nTry try but don't cry\n\n you did in %d try\n\n**********************************************\n", badluck);
break;
}
}
else if (guess < number)
{
count++;
badluck++;
printf("\n@@ ~~ Enter Greater number ~~ \n\n ");
if (count == 112)
{
printf("\nretry number is:%d,\n and level is :%d\n\nRETRY -->(0)\nEXIT--(1)\n", count, level);
scanf("%d", &retry);
}
}
else if (guess > number)
{
badluck++;
count++;
printf("\n@@ ~~ Enter Small number ~~ \n");
if (count == 102)
{
printf("\nretry number is:%d,\n and level is :%d\n\n\nRETRY -->(0)\nEXIT--(1)\n", count, level);
scanf("%d", &retry);
}
}
else
{
printf("what are you typing bro +_+");
}
} while (count < 102);
}
else
{
printf("select an option 1,2,3");
}
return 0;
}
2.rock paper ✂
code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int m[5], i = 0, a, b, r, p, c;
int user = 0;
int rock, paper, scissors;
char name1[20];
char comp;
int s1 = 0, s2 = 0;
puts("what is your name:");
gets(name1);
// printf("this is rock paper scissors game\nlets start");
// printf("\n");
for (i = 0; i < 5; i++)
{
printf("\n\npress any key :::\n");
getch();
srand(time(0));
int number = rand() % 100 + 1;
if (number < 33)
{
comp = 'r';
}
else if (number > 33 && number < 66)
{
comp = 'p';
}
else
{
comp = 's';
}
printf("\nwhat will you choose\n1 >rock\n2 >paper\n3> scissors\n");
scanf("%d", &user);
if (user == 1 && comp == 'r')
{
printf("\n********\n\nyou choose rock");
printf("\ncomputer choose rock \n\n");
printf("##>> draw\n");
}
else if (user == 1 && comp == 'p')
{
printf("\n********\n\nyou choose rock");
printf("\ncomputer choose paper\n\n");
printf("##>> computer wins\n");
s2++;
}
else if (user == 1 && comp == 's')
{
printf("\n********\n\nyou choose rock");
printf("\ncomputer choose scissors\n\n");
printf("##>> you wins\n");
s1++;
}
else if (user == 2 && comp == 's')
{
printf("\n********\n\nyou choose paper");
printf("\ncomputer choose scissor \n\n");
printf("##>> computer win\n");
s2++;
}
else if (user == 2 && comp == 'r')
{
printf("\n********\n\nyou choose paper");
printf("\ncomputer choose rock \n\n");
printf("##>> you win\n");
s1++;
}
else if (user == 2 && comp == 'p')
{
printf("\n********\n\nyou choose paper");
printf("\ncomputer choose paper\n\n");
printf("##>> draw\n");
}
else if (user == 2 && comp == 's')
{
printf("\n********\n\nyou choose ");
printf("\ncomputer choose scissor \n\n");
printf("##>> computer win\n");
}
else if (user == 3 && comp == 'r')
{
printf("\n********\n\nyou choose scissor");
printf("\ncomputer choose rock \n\n");
printf("##>> computer win\n");
s2++;
}
else if (user == 3 && comp == 'p')
{
printf("\n********\n\nyou choose scissor");
printf("\ncomputer choose paper\n\n");
printf("##>> you win\n");
s1++;
}
else if (user == 3 && comp == 's')
{
printf("\n********\n\nyou choose scissor");
printf("\ncomputer choose scissor \n\n");
printf("##>> draw\n");
}
else
{
printf("\ntype 1.2.3.\n");
}
}
if (s1 > s2)
{
printf("\n####\nYOU WON \n");
}
else
{
printf("\n####\nCOMPUTER WON \n");
}
return 0;
}
3.code for love
code:
#include<stdio.h>
int main (){
int a,b=1;
for (a=42;a>b;a--)
{
printf(" I Love You ");
}
return 0;
}
0 Comments