Tuesday, August 9, 2011

Chapter 4, exercise 2

2.  Rewrite the following code to be more readable.


#include <stdio.h>
int x,y; int main() { printf(
"\nEnter two numbers");scanf(
"%d %d",&x,&y);printf(
"\n\n%d is bigger",(x>y)?x:y);return 0;}


/* Note that I have put newlines in the two printf() parameters as well. */
#include <stdio.h>

int x, y;

int main()
{
  printf("\nEnter two numbers\n");
  scanf("%d %d", &x, &y);
  printf("\n\n%d is bigger\n", (x>y) ? x: y);
  return 0;
}

No comments:

Post a Comment