EVEN TRAINING

Maria loves playing soccer. Because she wants to play professionally when she grows up, she tracks her training by marking her calendar with a on the days that she trained, and a on the days she did not. She also loves math, and wants your help connecting her soccer training with what she's learning about even and odd numbers in school.
Given days of Maria's calendar history, print whether or not she trained for an even number of days (either or ), followed by the total number of days she trained.
Note: Code demonstrating how to read input from stdin is provided in your editor.
Input Format
The first line contains an integer, , denoting the number of days Maria tracked in her calendar.
The next line contains space-separated integers describing whether or not Maria trained each day. Recall that the number indicates that she did train, and indicates she did not.
Constraints
Output Format
Your output should consist of space-separated values on a single line. For the first value, you should print if Maria trained for an even number of days or if she did not. For the second value, you should print a single integer denoting the total number of days Maria trained.
Sample Input 0
4
1 1 0 0  
Sample Output 0
Yes 2
Sample Input 1
4
1 0 1 1
Sample Output 1
No 3
Explanation
Sample 0:

Maria trained on days; because this is an even number, we print .
Sample 1:

Maria trained on days; because this is an odd number, we print .


solution:
#include<stdio.h>
int main()
{
    int n;

scanf("%d",&n);
int arr[n],c=0,i;


    for(i=0;i<n;i++)
       scanf("%d",&arr[i]);
 
for(i=0;i<n;i++)
          {

if(arr[i]==1)
c++;

        }
if(c%2==0)
printf("Yes %d",c);
        else
      printf("No %d",c);


    return 0;
}

Comments

Popular posts from this blog

Pre-compiled Headers

CONNECTING WITH FTP-FILE TRANSFER PROTOCOL

PROBING THE INTERNET WITH TELNET: