Friday, March 20, 2015

Return Statement of c pgm



#include 
#include 
 
typedef int Bool;
 
const Bool TRUE = 1;
const Bool FALSE = 0;
 
char printableBool (Bool i)
 {
  if (i==FALSE) 
{
    return 'F';
  }
  else 
{
    return 'T';
  }
}
 
 
int main () 
{
 
  ifstream f1, f2; 
  ofstream f3;
  f1.open("exam");
  f2.open("key");
  f3.open("result");
 
  int runningSum;
  int ans, key, score;
 
  runningSum = 0;
 
  f1 >> ans;
  f2 >> key;
  while (f1)
 {
    if (ans == key)
 {
      runningSum = runningSum + 25;
      score = TRUE;
    }
    else 
{
      score = FALSE;
    }
    f3 << printableBool (score) << endl;
    f1 >> ans;
    f2 >> key;
  }
 
  f3 << endl << runningSum << endl;  
  
}
 

No comments:

Post a Comment