Wednesday 9 March 2016

IN / OUT


Ms. Sita, the faculty handling programming lab for you is very strict. Your seniors have told you that she will not allow you to enter the week's lab if you have not completed atleast half the number of problems given last week. Many of you didn't understand this statement and so they requested the good programmers from your batch to write a program to find whether a student will be allowed into a week's lab given the number of problems given last week and the number of problems solved by the student in that week.
Can you help in writing this program?

Input Format: 
Input consists of 2 integers. 
The first integer corresponds to the number of problems given and the second integer corresponds to the number of problems solved. 

Output Format: 
Output consists of the string “IN” or “OUT”. Refer sample input and output for further formatting specifications. 

Sample Input and Output: 
[All text in bold corresponds to input and the rest corresponds to output] 
Enter the number of problems given 
Enter the number of problems solved 
OUT

Code:
  #include<stdio.h>
int main()
{
  int mincount, maxcount, c;
  printf("Enter the number of problems given\n");
  scanf("%d",&maxcount);
  printf("Enter the number of problems solved\n");
  scanf("%d",&mincount);
  c=maxcount/2;
  if(mincount>c)
    printf("IN");
  else 
    printf("OUT");
  return 0;
}

1 comment:

  1. program is not correct as it doesn't shows IN while solving 50% questions....for example give input
    Enter the number of problems given
    10
    Enter the number of problems solved
    5
    Expected result
    IN
    Obtained result
    OUT

    ReplyDelete