Giter Site home page Giter Site logo

cprogram's Introduction

cprogram - An Amazing Project

The CP is a framework of international education that incorporates the values of the IB into a unique programme addressing the needs of students engaged in career-related education.

cprogram's People

Contributors

abhishek752 avatar baibhavtripathy avatar deadilyvirus avatar gvv2137 avatar harsh56-png avatar ishikagoel5628 avatar kvikash855 avatar lakshyadeepgogoi avatar mathurapgogoi avatar merinbenny avatar mohitgora55 avatar nikengoswami avatar nishisharma842004 avatar omchavan404 avatar pavanteja1999 avatar pieyushgupta avatar priya425mk avatar rishi0404 avatar rohank04 avatar royalsolanki avatar sau1506mya avatar saurabh-kumar0011 avatar seeditsolution avatar shiva439 avatar shobhitdwivedi31 avatar shrutipandey27 avatar shyam-123456 avatar sid050 avatar souparnapal avatar vishalbiji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cprogram's Issues

Please include the hacktober tag and contribute.md file

Sir , please include the Hacktober feast tag and label .or we will not be considered as participants. So sir please do it asap. And sir also include contribute.md file @austinnoronha @sayali1-deshmukh @karunvemala7 @mack12 @Ravindra3837

They say:)
Ineligible Repository
Your PR was submitted to a repository that is not participating in Hacktoberfest.
Maintainers of the repository can add the "hacktoberfest" topic to their repository if they wish to participate.

Not eligible for hactober fest

Your PR was submitted to a repository that is not participating in Hacktoberfest. Maintainers of the repository can add the "hacktoberfest" topic to their repository if they wish to participate. Alternatively, an individual PR can be opted-in with a maintainer adding the "hacktoberfest-accepted" label to the PR.

I have faced the following issue when i created a pull request. I kindly request the manager of this repository to please join hactober fest and make the necessary changes.

This repository is not counted for Hacktober feast

Sir , please include the Hacktober feast tag and label .or we will not be considered as participants. So sir please do it asap. And sir also include contribute.md file @austinnoronha @sayali1-deshmukh @karunvemala7 @mack12 @Ravindra3837

They say:)
Ineligible Repository
Your PR was submitted to a repository that is not participating in Hacktoberfest.
Maintainers of the repository can add the "hacktoberfest" topic to their repository if they wish to participate.

Tick tack toe

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include <windows.h>

int b[10] = {2,2,2,2,2,2,2,2,2,2};
int t = 1,f = 0;
int p,c;

void menu();
void go(int n);
void start_game();
void check_draw();
void draw_board();
void player_first();
void put_X_O(char ch,int pos);
COORD coord= {0,0}; // this is global variable
//center of axis is set to the top left cornor of the screen
void gotoxy(int x,int y)
{
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}

void main()
{
system("cls");
menu();
getch();

}

void menu()
{
int choice;
system("cls");
printf("\n--------MENU--------");
printf("\n1 : Play with X");
printf("\n2 : Play with O");
printf("\n3 : Exit");
printf("\nEnter your choice:>");
scanf("%d",&choice);
t = 1;
switch (choice)
{
case 1:
p = 1;
c = 0;
player_first();
break;
case 2:
p = 0;
c = 1;
start_game();
break;
case 3:
exit(1);
default:
menu();
}
}

int make2()
{
if(b[5] == 2)
return 5;
if(b[2] == 2)
return 2;
if(b[4] == 2)
return 4;
if(b[6] == 2)
return 6;
if(b[8] == 2)
return 8;
return 0;
}

int make4()
{
if(b[1] == 2)
return 1;
if(b[3] == 2)
return 3;
if(b[7] == 2)
return 7;
if(b[9] == 2)
return 9;
return 0;
}

int posswin(int p)
{
// p==1 then X p==0 then O
int i;
int check_val,pos;

if(p == 1)
    check_val = 18;
else
    check_val = 50;

i = 1;
while(i<=9)//row check
{
    if(b[i] * b[i+1] * b[i+2] == check_val)
    {
        if(b[i] == 2)
            return i;
        if(b[i+1] == 2)
            return i+1;
        if(b[i+2] == 2)
            return i+2;
    }
    i+=3;
}

i = 1;
while(i<=3)//column check
{
    if(b[i] * b[i+3] * b[i+6] == check_val)
    {
        if(b[i] == 2)
            return i;
        if(b[i+3] == 2)
            return i+3;
        if(b[i+6] == 2)
            return i+6;
    }
    i++;
}

if(b[1] * b[5] * b[9] == check_val)
{
    if(b[1] == 2)
        return 1;
    if(b[5] == 2)
        return 5;
    if(b[9] == 2)
        return 9;
}

if(b[3] * b[5] * b[7] == check_val)
{
    if(b[3] == 2)
        return 3;
    if(b[5] == 2)
        return 5;
    if(b[7] == 2)
        return 7;
}
return 0;

}

void go(int n)
{
if(t % 2)
b[n] = 3;
else
b[n] = 5;
turn++;
}

void player_first()
{
int pos;

check_draw();
draw_board();
gotoxy(30,18);
printf("Your Turn :> ");
scanf("%d",&pos);

if(b[pos] != 2)
    player_first();

if(pos == posswin(player))
{
    go(pos);
    draw_board();
    gotoxy(30,20);
    //textcolor(128+RED);
    printf("Player Wins");
    getch();
    exit(0);
}

go(pos);
draw_board();
start_game();

}

void start_game()
{
// p==1 then X p==0 then O
if(posswin(c))
{
go(posswin(c));
f = 1;
}
else if(posswin(p))
go(posswin(p));
else if(make2())
go(make2());
else
go(make4());
draw_board();

if(f)
{
    gotoxy(30,20);
    //textcolor(128+RED);
    printf("Computer wins");
    getch();
}
else
    player_first();

}

void check_draw()
{
if(turn > 9)
{
gotoxy(30,20);
//textcolor(128+RED);
printf("Game Draw");
getch();
exit(0);
}
}

void draw_board()
{
int j;

for(j=9; j<17; j++)
{
    gotoxy(35,j);
    printf("|       |");
}
gotoxy(28,11);
printf("-----------------------");
gotoxy(28,14);
printf("-----------------------");

for(j=1; j<10; j++)
{
    if(b[j] == 3)
        put_X_O('X',j);
    else if(b[j] == 5)
        put_X_O('O',j);
}

}

void put_X_O(char ch,int pos)
{
int m;
int x = 31, y = 10;

m = pos;

if(m > 3)
{
    while(m > 3)
    {
        y += 3;
        m -= 3;
    }
}
if(pos % 3 == 0)
    x += 16;
else
{
    pos %= 3;
    pos--;
    while(pos)
    {
        x+=8;
        pos--;
    }
}
gotoxy(x,y);
printf("%c",ch);

}

Game

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
void show_record();
void reset_score();
void help();
void edit_score(float , char []);
int main()
{
int countr,r,r1,count,i,n;
float score;
char choice;
char playername[20];
mainhome:
system("cls");
printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

 printf("\n\t\t\t   WELCOME ");
 printf("\n\t\t\t      to ");
 printf("\n\t\t\t   THE GAME ");
 printf("\n\t\t________________________________________");
 printf("\n\t\t________________________________________");
 printf("\n\t\t   BECOME A MILLIONAIRE!!!!!!!!!!!    ") ;
 printf("\n\t\t________________________________________");
 printf("\n\t\t________________________________________");
 printf("\n\t\t > Press S to start the game");
 printf("\n\t\t > Press V to view the highest score  ");
 printf("\n\t\t > Press R to reset score");
 printf("\n\t\t > press H for help            ");
 printf("\n\t\t > press Q to quit             ");
 printf("\n\t\t________________________________________\n\n");
 choice=toupper(getch());
 if (choice=='V')
{
show_record();
goto mainhome;
}
 else if (choice=='H')
{
help();getch();
goto mainhome;
}
else if (choice=='R')
{reset_score();
getch();
goto mainhome;}
else if (choice=='Q')
exit(1);
else if(choice=='S')
{
 system("cls");

printf("\n\n\n\n\n\n\n\n\n\n\t\t\tResister your name:");
 gets(playername);

system("cls");
printf("\n ------------------  Welcome %s to C Program Quiz Game --------------------------",playername);
printf("\n\n Here are some tips you might wanna know before playing:");
printf("\n -------------------------------------------------------------------------");
printf("\n >> There are 2 rounds in this Quiz Game,WARMUP ROUND & CHALLANGE ROUND");
printf("\n >> In warmup round you will be asked a total of 3 questions to test your");
printf("\n    general knowledge. You are eligible to play the game if you give atleast 2");
printf("\n    right answers, otherwise you can't proceed further to the Challenge Round.");
printf("\n >> Your game starts with CHALLANGE ROUND. In this round you will be asked a");
printf("\n    total of 10 questions. Each right answer will be awarded $100,000!");
printf("\n    By this way you can win upto ONE MILLION cash prize!!!!!..........");
printf("\n >> You will be given 4 options and you have to press A, B ,C or D for the");
printf("\n    right option.");
printf("\n >> You will be asked questions continuously, till right answers are given");
printf("\n >> No negative marking for wrong answers!");
printf("\n\n\t!!!!!!!!!!!!! ALL THE BEST !!!!!!!!!!!!!");
printf("\n\n\n Press Y  to start the game!\n");
printf("\n Press any other key to return to the main menu!");
if (toupper(getch())=='Y')
	{
	    goto home;
    }
else
	{
    goto mainhome;
   system("cls");
   }

 home:
 system("cls");
 count=0;
 for(i=1;i<=3;i++)
 {
system("cls");
 r1=i;


 switch(r1)
	{
	case 1:
	printf("\n\nWhich of the following is a Palindrome number?");
	printf("\n\nA.42042\t\tB.101010\n\nC.23232\t\tD.01234");
	if (toupper(getch())=='C')
		{
		    printf("\n\nCorrect!!!");count++;
		    getch();
		    break;

}
else
{
printf("\n\nWrong!!! The correct answer is C.23232");
getch();
break;
}

    case 2:
	printf("\n\n\nThe country with the highest environmental performance index is...");
	printf("\n\nA.France\t\tB.Denmark\n\nC.Switzerland\t\tD.Finland");
	if (toupper(getch())=='C')
		{printf("\n\nCorrect!!!");count++;
		getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is C.Switzerland");
	       getch();
	       break;}

    case 3:
	printf("\n\n\nWhich animal laughs like human being?");
	printf("\n\nA.Polar Bear\t\tB.Hyena\n\nC.Donkey\t\tD.Chimpanzee");
	if (toupper(getch())=='B')
		{printf("\n\nCorrect!!!");count++;
		getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is B.Hyena");
	       getch();
	       break;}

    case 4:
	printf("\n\n\nWho was awarded the youngest player award in Fifa World Cup 2006?");
	printf("\n\nA.Wayne Rooney\t\tB.Lucas Podolski\n\nC.Lionel Messi\t\tD.Christiano Ronaldo");
	if (toupper(getch())=='B')
		{printf("\n\nCorrect!!!");count++;
		getch();
		 break;}
	else
	       {printf("\n\nWrong!!! The correct answer is B.Lucas Podolski");
	       getch();
	       break;}

    case 5:
    printf("\n\n\nWhich is the third highest mountain in the world?");
    printf("\n\nA.Mt. K2\t\tB.Mt. Kanchanjungha\n\nC.Mt. Makalu\t\tD.Mt. Kilimanjaro");
    if (toupper(getch())=='B')
           {printf("\n\nCorrect!!!");count++;
           getch();
            break;}
    else
	       {printf("\n\nWrong!!! The correct answer is B.Mt. Kanchanjungha");
	       getch();
	       break;}

    case 6:
	printf("\n\n\nWhat is the group of frogs known as?");
	printf("\n\nA.A traffic\t\tB.A toddler\n\nC.A police\t\tD.An Army");
	if (toupper(getch())=='D' )
		{printf("\n\nCorrect!!!");count++;
		getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is D.An Army");
	       getch();
	       break;}}
	       }

if(count>=2)
{goto test;}
else
{
system("cls");
printf("\n\nSORRY YOU ARE NOT ELIGIBLE TO PLAY THIS GAME, BETTER LUCK NEXT TIME");
getch();
goto mainhome;
}
 test:
 system("cls");
 printf("\n\n\t*** CONGRATULATION %s you are eligible to play the Game ***",playername);
 printf("\n\n\n\n\t!Press any key to Start the Game!");
 if(toupper(getch())=='p')
	{goto game;}

game:
countr=0;
for(i=1;i<=10;i++)
{system("cls");
r=i;

 switch(r)
	{
	case 1:
	printf("\n\nWhat is the National Game of England?");
	printf("\n\nA.Football\t\tB.Basketball\n\nC.Cricket\t\tD.Baseball");
	if (toupper(getch())=='C')
		{printf("\n\nCorrect!!!");countr++;getch();
		 break;getch();}
	else
	       {printf("\n\nWrong!!! The correct answer is C.Cricket");getch();
	       goto score;
	       break;}

	case 2:
	printf("\n\n\nStudy of Earthquake is called............,");
	printf("\n\nA.Seismology\t\tB.Cosmology\n\nC.Orology\t\tD.Etimology");
	if (toupper(getch())=='A')
		{printf("\n\nCorrect!!!");countr++;getch();
		 break;}
	else
	       {printf("\n\nWrong!!! The correct answer is A.Seismology");getch();
	      goto score;
	       break;
	       }

    case 3:
	printf("\n\n\nAmong the top 10 highest peaks in the world, how many lie in Nepal? ");
	printf("\n\nA.6\t\tB.7\n\nC.8\t\tD.9");
	if (toupper(getch())=='C')
		{printf("\n\nCorrect!!!");countr++;getch();
		 break;}
	else
	       {printf("\n\nWrong!!! The correct answer is C.8");getch();
	       goto score;
	       break;}

    case 4:
	printf("\n\n\nThe Laws of Electromagnetic Induction were given by?");
	printf("\n\nA.Faraday\t\tB.Tesla\n\nC.Maxwell\t\tD.Coulomb");
	if (toupper(getch())=='A')
		{printf("\n\nCorrect!!!");countr++;getch();
		 break;}
	else
	       {
            printf("\n\nWrong!!! The correct answer is A.Faraday");getch();
	       goto score;
	       break;
	       }

    case 5:
	printf("\n\n\nIn what unit is electric power measured?");
	printf("\n\nA.Coulomb\t\tB.Watt\n\nC.Power\t\tD.Units");
	if (toupper(getch())=='B')
		{printf("\n\nCorrect!!!");countr++;getch(); break;}
	else
	       {
	           printf("\n\nWrong!!! The correct answer is B.Power");
	       getch();
	       goto score;
	       break;
	       }

	case 6:
	printf("\n\n\nWhich element is found in Vitamin B12?");
	printf("\n\nA.Zinc\t\tB.Cobalt\n\nC.Calcium\t\tD.Iron");
	if (toupper(getch())=='B' )
		{printf("\n\nCorrect!!!");countr++;getch();
		 break;}
	else
	       {printf("\n\nWrong!!! The correct answer is B.Cobalt");goto score;
	       getch();
	       break;}

    case 7:
	printf("\n\n\nWhat is the National Name of Japan?");
	printf("\n\nA.Polska\t\tB.Hellas\n\nC.Drukyul\t\tD.Nippon");
	if (toupper(getch())=='D')
		{printf("\n\nCorrect!!!");countr++;getch();
		 break;}
	else
	       {printf("\n\nWrong!!! The correct answer is D.Nippon");getch();
	       goto score;
	       break;}

    case 8:
	printf("\n\n\nHow many times a piece of paper can be folded at the most?");
	printf("\n\nA.6\t\tB.7\n\nC.8\t\tD.Depends on the size of paper");
	if (toupper(getch())=='B')
		{printf("\n\nCorrect!!!");countr++;getch(); break;}
	else
	       {printf("\n\nWrong!!! The correct answer is B.7");getch();
	       goto score;
	       break;}

    case 9:
	printf("\n\n\nWhat is the capital of Denmark?");
	printf("\n\nA.Copenhagen\t\tB.Helsinki\n\nC.Ajax\t\tD.Galatasaray");
	if (toupper(getch())=='A')
		{printf("\n\nCorrect!!!");countr++; getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is A.Copenhagen");getch();
	       goto score;
	       break;}

    case 10:
	printf("\n\n\nWhich is the longest River in the world?");
	printf("\n\nA.Nile\t\tB.Koshi\n\nC.Ganga\t\tD.Amazon");
	if (toupper(getch())=='A')
		{printf("\n\nCorrect!!!");countr++;getch(); break;}
	else
	       {printf("\n\nWrong!!! The correct answer is A.Nile");getch();break;goto score;}

    case 11:
	printf("\n\n\nWhat is the color of the Black Box in aeroplanes?");
	printf("\n\nA.White\t\tB.Black\n\nC.Orange\t\tD.Red");
	if (toupper(getch())=='C')
		{printf("\n\nCorrect!!!");countr++;getch();
		 break;}
	else
          {printf("\n\nWrong!!! The correct answer is C.Orange");getch();
          break;goto score;}

    case 12:
	printf("\n\n\nWhich city is known at 'The City of Seven Hills'?");
	printf("\n\nA.Rome\t\tB.Vactican City\n\nC.Madrid\t\tD.Berlin");
	if (toupper(getch())=='A')
		  {printf("\n\nCorrect!!!");countr++;getch();
		   break;}
	else
          {printf("\n\nWrong!!! The correct answer is A.Rome");getch();
          break;goto score;}

	case 13:
	printf("\n\n\nName the country where there no mosquitoes are found?");
	printf("\n\nA.Japan\t\tB.Italy\n\nC.Argentina\t\tD.France");
	if (toupper(getch())=='D')
		{printf("\n\nCorrect!!!");countr++;getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is D.France");getch();
	       break;goto score;}

    case 14:
	printf("\n\n\nWho is the author of 'Pulpasa Cafe'?");
	printf("\n\nA.Narayan Wagle\t\tB.Lal Gopal Subedi\n\nC.B.P. Koirala\t\tD.Khagendra Sangraula");
	if (toupper(getch())=='A')
		{printf("\n\nCorrect!!!");countr++;getch();
		 break;}
	else
	       {printf("\n\nWrong!!! The correct answer is A.Narayan Wagle");getch();
	       break;goto score;}

	case 15:
	printf("\n\n\nWhich Blood Group is known as the Universal Recipient?");
	printf("\n\nA.A\t\tB.AB\n\nC.B\t\tD.O");
	if (toupper(getch())=='B')
		{printf("\n\nCorrect!!!");countr++;getch();
		 break;}
	else
	       {printf("\n\nWrong!!! The correct answer is B.AB");getch();
	       goto score;
	       break;}

	case 16:
	printf("\n\n\nWhat is the unit of measurement of distance between Stars?");
	printf("\n\nA.Light Year\t\tB.Coulomb\n\nC.Nautical Mile\t\tD.Kilometer");
	if (toupper(getch())=='A')
		{printf("\n\nCorrect!!!");countr++; getch();
		break;
		}
	else
	       {printf("\n\nWrong!!! The correct answer is A.Light Year");getch();
	       goto score;
	       break;}


	case 17:
	printf("\n\n\nThe country famous for Samba Dance is........");
	printf("\n\nA.Brazil\t\tB.Venezuela\n\nC.Nigeria\t\tD.Bolivia");
	if (toupper(getch())=='A')
		{printf("\n\nCorrect!!!");countr++; getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is A.Brazil");getch();goto score;
	       break;}

	case 18:
	printf("\n\n\nWind speed is measure by__________?");
	printf("\n\nA.Lysimeter\t\tB.Air vane\n\nC.Hydrometer\t\tD.Anemometer\n\n");
	if (toupper(getch())=='D')
		{printf("\n\nCorrect!!!");countr++; getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is D.Anemometer");getch();goto score;
	       break;}

	case 19:
	printf("\n\n\nWhich city in the world is popularly known as The City of Temple?");
	printf("\n\nA.Delhi\tB.Bhaktapur\n\nC.Kathmandu\tD.Agra\n\n");
	if (toupper(getch())=='C')
		{printf("\n\nCorrect!!!");countr++; getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is C.Kathmandu");getch();goto score;
	       break;}

	case 20:
	printf("\n\n\nWhich hardware was used in the First Generation Computer?");
	printf("\n\nA.Transistor\t\tB.Valves\n\nC.I.C\t\tD.S.S.I");
	if (toupper(getch())=='B')
		{printf("\n\nCorrect!!!");countr++; getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is B.Valves");getch();goto score;
	       break;}

	case 21:
	printf("\n\n\nOzone plate is being destroyed regularly because of____ ?");
	printf("\n\nA.L.P.G\t\tB.Nitrogen\n\nC.Methane\t\tD. C.F.C");
	if (toupper(getch())=='D')
		{printf("\n\nCorrect!!!");countr++; getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is D. C.F.C");getch();goto score;
	       break;}

	case 22:
	printf("\n\n\nWho won the Women's Australian Open Tennis in 2007?");
	printf("\n\nA.Martina Hingis\t\tB.Maria Sarapova\n\nC.Kim Clijster\t\tD.Serena Williams");
	if (toupper(getch())=='D')
		{printf("\n\nCorrect!!!");countr++; getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is D.Serena Williams");getch();goto score;
	       break;}

	case 23:
	printf("\n\n\nWhich film was awarded the Best Motion Picture at Oscar in 2010?");
	printf("\n\nA.The Secret in their Eyes\t\tB.Shutter Island\n\nC.The King's Speech\t\tD.The Reader");
	if (toupper(getch())=='C')
		{printf("\n\nCorrect!!!");countr++; getch();
		break;}
	else
	       {printf("\n\nWrong!!! The correct answer is C.The King's Speech");getch();goto score;
	       break;}}}
score:
system("cls");
score=(float)countr*100000;
if(score>0.00 && score<1000000)
{
   printf("\n\n\t\t**************** CONGRATULATION *****************");
     printf("\n\t You won $%.2f",score);goto go;}

 else if(score==1000000.00)
{
    printf("\n\n\n \t\t**************** CONGRATULATION ****************");
    printf("\n\t\t\t\t YOU ARE A MILLIONAIRE!!!!!!!!!");
    printf("\n\t\t You won $%.2f",score);
    printf("\t\t Thank You!!");
}
 else

{
printf("\n\n\t******** SORRY YOU DIDN'T WIN ANY CASH ********");
printf("\n\t\t Thanks for your participation");
printf("\n\t\t TRY AGAIN");goto go;}

go:
puts("\n\n Press Y if you want to play next game");
puts(" Press any key if you want to go main menu");
if (toupper(getch())=='Y')
	goto home;
else
	{
	edit_score(score,playername);
	goto mainhome;}}}

void show_record()
{system("cls");
char name[20];
float scr;
FILE f;
f=fopen("score.txt","r");
fscanf(f,"%s%f",&name,&scr);
printf("\n\n\t\t
************************************************************");
printf("\n\n\t\t %s has secured the Highest Score %0.2f",name,scr);
printf("\n\n\t\t*************************************************************");
fclose(f);
getch();}

void reset_score()
{system("cls");
float sc;
char nm[20];
FILE *f;
f=fopen("score.txt","r+");
fscanf(f,"%s%f",&nm,&sc);
sc=0;
fprintf(f,"%s,%.2f",nm,sc);
fclose(f);}

void help()
{system("cls");
printf("\n\n HELP");
printf("\n -------------------------------------------------------------------------");
printf("\n ......................... C program Quiz Game...........");
printf("\n >> There are two rounds in the game, WARMUP ROUND & CHALLANGE ROUND");
printf("\n >> In warmup round you will be asked a total of 3 questions to test your general");
printf("\n knowledge. You will be eligible to play the game if you can give atleast 2");
printf("\n right answers otherwise you can't play the Game...........");
printf("\n >> Your game starts with the CHALLANGE ROUND. In this round you will be asked");
printf("\n total 10 questions each right answer will be awarded $100,000.");
printf("\n By this way you can win upto ONE MILLION cash prize in USD...............");
printf("\n >> You will be given 4 options and you have to press A, B ,C or D for the");
printf("\n right option");
printf("\n >> You will be asked questions continuously if you keep giving the right answers.");
printf("\n >> No negative marking for wrong answers");

printf("\n\n\t*********************BEST OF LUCK*********************************");
printf("\n\n\t*****C PROGRAM QUIZ GAME is developed by CODE WITH C TEAM********");}

void edit_score(float score, char plnm[20])
{system("cls");
float sc;
char nm[20];
FILE *f;
f=fopen("score.txt","r");
fscanf(f,"%s%f",&nm,&sc);
if (score>=sc)
{ sc=score;
fclose(f);
f=fopen("score.txt","w");
fprintf(f,"%s\n%.2f",plnm,sc);
fclose(f);}}

Calender

#include<stdio.h>
#include<conio.h>
#include<windows.h>
struct Date{
int dd;
int mm;
int yy;
};
struct Date date;

struct Remainder{
int dd;
int mm;
char note[50];
};
struct Remainder R;

COORD xy = {0, 0};

void gotoxy (int x, int y)
{
xy.X = x; xy.Y = y; // X and Y coordinates
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), xy);
}

//This will set the forground color for printing in a console window.
void SetColor(int ForgC)
{
WORD wColor;
//We will need this handle to get the current background attribute
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;

 //We use csbi for the wAttributes word.
 if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
 {
    //Mask out all but the background attribute, and add in the forgournd color
      wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
      SetConsoleTextAttribute(hStdOut, wColor);
 }
 return;

}

void ClearColor(){
SetColor(15);
}

void ClearConsoleToColors(int ForgC, int BackC)
{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
//Get the handle to the current output buffer...
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
//This is used to reset the carat/cursor to the top left.
COORD coord = {0, 0};
//A return value... indicating how many chars were written
// not used but we need to capture this since it will be
// written anyway (passing NULL causes an access violation).
DWORD count;

 //This is a structure containing all of the console info
 // it is used here to find the size of the console.
 CONSOLE_SCREEN_BUFFER_INFO csbi;
 //Here we will set the current color
 SetConsoleTextAttribute(hStdOut, wColor);
 if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
 {
      //This fills the buffer with a given character (in this case 32=space).
      FillConsoleOutputCharacter(hStdOut, (TCHAR) 32, csbi.dwSize.X * csbi.dwSize.Y, coord, &count);

      FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, csbi.dwSize.X * csbi.dwSize.Y, coord, &count );
      //This will set our cursor position for the next print statement.
      SetConsoleCursorPosition(hStdOut, coord);
 }
 return;

}

void SetColorAndBackground(int ForgC, int BackC)
{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
return;
}

int check_leapYear(int year){ //checks whether the year passed is leap year or not
if(year % 400 == 0 || (year % 100!=0 && year % 4 ==0))
return 1;
return 0;
}

void increase_month(int *mm, int *yy){ //increase the month by one
++*mm;
if(*mm > 12){
++*yy;
*mm = *mm - 12;
}
}

void decrease_month(int *mm, int *yy){ //decrease the month by one
--*mm;
if(*mm < 1){
--*yy;
if(*yy<1600){
printf("No record available");
return;
}
*mm = *mm + 12;
}
}

int getNumberOfDays(int month,int year){ //returns the number of days in given month
switch(month){ //and year
case 1 : return(31);
case 2 : if(check_leapYear(year)==1)
return(29);
else
return(28);
case 3 : return(31);
case 4 : return(30);
case 5 : return(31);
case 6 : return(30);
case 7 : return(31);
case 8 : return(31);
case 9 : return(30);
case 10: return(31);
case 11: return(30);
case 12: return(31);
default: return(-1);
}
}

char *getName(int day){ //returns the name of the day
switch(day){
case 0 :return("Sunday");
case 1 :return("Monday");
case 2 :return("Tuesday");
case 3 :return("Wednesday");
case 4 :return("Thursday");
case 5 :return("Friday");
case 6 :return("Saturday");
default:return("Error in getName() module.Invalid argument passed");
}
}

void print_date(int mm, int yy){ //prints the name of month and year
printf("---------------------------\n");
gotoxy(25,6);
switch(mm){
case 1: printf("January"); break;
case 2: printf("February"); break;
case 3: printf("March"); break;
case 4: printf("April"); break;
case 5: printf("May"); break;
case 6: printf("June"); break;
case 7: printf("July"); break;
case 8: printf("August"); break;
case 9: printf("September"); break;
case 10: printf("October"); break;
case 11: printf("November"); break;
case 12: printf("December"); break;
}
printf(" , %d", yy);
gotoxy(20,7);
printf("---------------------------");
}
int getDayNumber(int day,int mon,int year){ //retuns the day number
int res = 0, t1, t2, y = year;
year = year - 1600;
while(year >= 100){
res = res + 5;
year = year - 100;
}
res = (res % 7);
t1 = ((year - 1) / 4);
t2 = (year-1)-t1;
t1 = (t1*2)+t2;
t1 = (t1%7);
res = res + t1;
res = res%7;
t2 = 0;
for(t1 = 1;t1 < mon; t1++){
t2 += getNumberOfDays(t1,y);
}
t2 = t2 + day;
t2 = t2 % 7;
res = res + t2;
res = res % 7;
if(y > 2000)
res = res + 1;
res = res % 7;
return res;
}

char *getDay(int dd,int mm,int yy){
int day;
if(!(mm>=1 && mm<=12)){
return("Invalid month value");
}
if(!(dd>=1 && dd<=getNumberOfDays(mm,yy))){
return("Invalid date");
}
if(yy>=1600){
day = getDayNumber(dd,mm,yy);
day = day%7;
return(getName(day));
}else{
return("Please give year more than 1600");
}
}

int checkNote(int dd, int mm){
FILE *fp;
fp = fopen("note.dat","rb");
if(fp == NULL){
printf("Error in Opening the file");
}
while(fread(&R,sizeof(R),1,fp) == 1){
if(R.dd == dd && R.mm == mm){
fclose(fp);
return 1;
}
}
fclose(fp);
return 0;
}

void printMonth(int mon,int year,int x,int y){ //prints the month with all days
int nod, day, cnt, d = 1, x1 = x, y1 = y, isNote = 0;
if(!(mon>=1 && mon<=12)){
printf("INVALID MONTH");
getch();
return;
}
if(!(year>=1600)){
printf("INVALID YEAR");
getch();
return;
}
gotoxy(20,y);
print_date(mon,year);
y += 3;
gotoxy(x,y);
printf("S M T W T F S ");
y++;
nod = getNumberOfDays(mon,year);
day = getDayNumber(d,mon,year);
switch(day){ //locates the starting day in calender
case 0 :
x=x;
cnt=1;
break;
case 1 :
x=x+4;
cnt=2;
break;
case 2 :
x=x+8;
cnt=3;
break;
case 3 :
x=x+12;
cnt=4;
break;
case 4 :
x=x+16;
cnt=5;
break;
case 5 :
x=x+20;
cnt=6;
break;
case 6 :
x=x+24;
cnt=7;
break;
default :
printf("INVALID DATA FROM THE getOddNumber()MODULE");
return;
}
gotoxy(x,y);
if(cnt == 1){
SetColor(12);
}
if(checkNote(d,mon)==1){
SetColorAndBackground(15,12);
}
printf("%02d",d);
SetColorAndBackground(15,1);
for(d=2;d<=nod;d++){
if(cnt%7==0){
y++;
cnt=0;
x=x1-4;
}
x = x+4;
cnt++;
gotoxy(x,y);
if(cnt==1){
SetColor(12);
}else{
ClearColor();
}
if(checkNote(d,mon)==1){
SetColorAndBackground(15,12);
}
printf("%02d",d);
SetColorAndBackground(15,1);
}
gotoxy(8, y+2);
SetColor(14);
printf("Press 'n' to Next, Press 'p' to Previous and 'q' to Quit");
gotoxy(8,y+3);
printf("Red Background indicates the NOTE, Press 's' to see note: ");
ClearColor();
}

void AddNote(){
FILE *fp;
fp = fopen("note.dat","ab+");
system("cls");
gotoxy(5,7);
printf("Enter the date(DD/MM): ");
scanf("%d%d",&R.dd, &R.mm);
gotoxy(5,8);
printf("Enter the Note(50 character max): ");
fflush(stdin);
scanf("%[^\n]",R.note);
if(fwrite(&R,sizeof(R),1,fp)){
gotoxy(5,12);
puts("Note is saved sucessfully");
fclose(fp);
}else{
gotoxy(5,12);
SetColor(12);
puts("\aFail to save!!\a");
ClearColor();
}
gotoxy(5,15);
printf("Press any key............");
getch();
fclose(fp);
}

void showNote(int mm){
FILE *fp;
int i = 0, isFound = 0;
system("cls");
fp = fopen("note.dat","rb");
if(fp == NULL){
printf("Error in opening the file");
}
while(fread(&R,sizeof(R),1,fp) == 1){
if(R.mm == mm){
gotoxy(10,5+i);
printf("Note %d Day = %d: %s", i+1, R.dd, R.note);
isFound = 1;
i++;
}
}
if(isFound == 0){
gotoxy(10,5);
printf("This Month contains no note");
}
gotoxy(10,7+i);
printf("Press any key to back.......");
getch();

}

int main(){
ClearConsoleToColors(15, 1);
SetConsoleTitle("Calender Project - Programming-technique.blogspot.com");
int choice;
char ch = 'a';
while(1){
system("cls");
printf("1. Find Out the Day\n");
printf("2. Print all the day of month\n");
printf("3. Add Note\n");
printf("4. EXIT\n");
printf("ENTER YOUR CHOICE : ");
scanf("%d",&choice);
system("cls");
switch(choice){
case 1:
printf("Enter date (DD MM YYYY) : ");
scanf("%d %d %d",&date.dd,&date.mm,&date.yy);
printf("Day is : %s",getDay(date.dd,date.mm,date.yy));
printf("\nPress any key to continue......");
getch();
break;
case 2 :
printf("Enter month and year (MM YYYY) : ");
scanf("%d %d",&date.mm,&date.yy);
system("cls");
while(ch!='q'){
printMonth(date.mm,date.yy,20,5);
ch = getch();
if(ch == 'n'){
increase_month(&date.mm,&date.yy);
system("cls");
printMonth(date.mm,date.yy,20,5);
}else if(ch == 'p'){
decrease_month(&date.mm,&date.yy);
system("cls");
printMonth(date.mm,date.yy,20,5);
}else if(ch == 's'){
showNote(date.mm);
system("cls");
}
}
break;
case 3:
AddNote();
break;
case 4 :
exit(0);
}
}
return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.