Click here to Skip to main content
15,886,689 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Victor Nijegorodov26-Dec-17 23:03
Victor Nijegorodov26-Dec-17 23:03 
GeneralRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Tarun Jha26-Dec-17 23:17
Tarun Jha26-Dec-17 23:17 
AnswerRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Richard MacCutchan26-Dec-17 22:29
mveRichard MacCutchan26-Dec-17 22:29 
GeneralRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Tarun Jha26-Dec-17 22:43
Tarun Jha26-Dec-17 22:43 
GeneralRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Richard MacCutchan26-Dec-17 23:28
mveRichard MacCutchan26-Dec-17 23:28 
GeneralRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Tarun Jha27-Dec-17 0:23
Tarun Jha27-Dec-17 0:23 
GeneralRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Richard MacCutchan27-Dec-17 0:25
mveRichard MacCutchan27-Dec-17 0:25 
GeneralRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Tarun Jha27-Dec-17 1:09
Tarun Jha27-Dec-17 1:09 
And here is the working code Smile | :)

#include <stdio.h>
#include <string.h>

int main()
{
	int i, log, j, c1=0, c2=0;
	char team_1[100], team_2[100], input[100], ch;

	printf("Enter name of Team-1: \n");
	gets(team_1);

	printf("Enter the name of Team-2\n");
	gets(team_2);

	if(strcmp(team_1, team_2)==0)
    {
        printf("Oops! both names are same. Please enter again: \n");
        while(strcmp(team_1, team_2)==0)
        {
            printf("Enter name of Team-1: \n");
            gets(team_1);

            printf("Enter the name of Team-2\n");
            gets(team_2);
        }
    }

    printf("Enter the number of logs: \n");
	scanf("%d%*c", &log);

	for(i=0; i<log; i++)
	{
		printf("\nEnter log-%d\n", i+1);
		gets(input);

		if(strcmp(input, team_1) == 0)
			c1++;

		else if(strcmp(input, team_2) == 0)
			c2++;
		else
			printf("Invalid entry !\n");

        for(j=0; j<=strlen(input); j++)
        {
            input[j]=0;
        }
	}

	if(c1>c2)
		printf("\nTeam-1 wins");
	else if(c1<c2)
		printf("\nTeam-2 wins");
	else
		printf("\nIt's a tie");

	return 0;
}

AnswerRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Tarun Jha27-Dec-17 1:11
Tarun Jha27-Dec-17 1:11 
AnswerRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Vaclav_28-Dec-17 13:24
Vaclav_28-Dec-17 13:24 
GeneralRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Victor Nijegorodov28-Dec-17 21:17
Victor Nijegorodov28-Dec-17 21:17 
GeneralRe: To write a c program to maintain a log of football match b/w 2 teams and then compare the results of the log entered by user and announce the winner. Pin
Tarun Jha31-Dec-17 12:30
Tarun Jha31-Dec-17 12:30 
QuestionClasses hierarchy? Pin
Vaclav_24-Dec-17 7:53
Vaclav_24-Dec-17 7:53 
AnswerRe: Classes hierarchy? Pin
Rick York24-Dec-17 10:36
mveRick York24-Dec-17 10:36 
QuestionCode consuming lot of RAM (Memory) Pin
User 1350945018-Dec-17 23:21
professionalUser 1350945018-Dec-17 23:21 
AnswerRe: Code consuming lot of RAM (Memory) Pin
Manish K. Agarwal19-Dec-17 0:24
Manish K. Agarwal19-Dec-17 0:24 
GeneralRe: Code consuming lot of RAM (Memory) Pin
User 1350945019-Dec-17 0:30
professionalUser 1350945019-Dec-17 0:30 
GeneralRe: Code consuming lot of RAM (Memory) Pin
Manish K. Agarwal19-Dec-17 0:48
Manish K. Agarwal19-Dec-17 0:48 
GeneralRe: Code consuming lot of RAM (Memory) Pin
User 1350945019-Dec-17 2:02
professionalUser 1350945019-Dec-17 2:02 
QuestionRe: Code consuming lot of RAM (Memory) Pin
Jochen Arndt19-Dec-17 0:57
professionalJochen Arndt19-Dec-17 0:57 
AnswerRe: Code consuming lot of RAM (Memory) Pin
User 1350945019-Dec-17 2:01
professionalUser 1350945019-Dec-17 2:01 
GeneralRe: Code consuming lot of RAM (Memory) Pin
Jochen Arndt19-Dec-17 2:35
professionalJochen Arndt19-Dec-17 2:35 
AnswerRe: Code consuming lot of RAM (Memory) Pin
Jochen Arndt19-Dec-17 2:59
professionalJochen Arndt19-Dec-17 2:59 
QuestionRe: Code consuming lot of RAM (Memory) Pin
David Crow19-Dec-17 4:12
David Crow19-Dec-17 4:12 
AnswerRe: Code consuming lot of RAM (Memory) Pin
User 1350945019-Dec-17 5:14
professionalUser 1350945019-Dec-17 5:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.