Search This Blog

Thursday, October 13, 2011

Write a program to declaring operand as a block variable defined in if block

   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:  #include<math.h>
   4:  void main()
   5:  {
   6:  int x;
   7:  printf("Enter an interger num:\n");
   8:  scanf("%d",&x);
   9:  if(x>0)
  10:  {
  11:  float r;
  12:  r=1/float(x);
  13:  printf("\nReciprocal of %d is: %f\n",x,r);
  14:  }
  15:  else
  16:  printf("X is too small to evaluate reciprocal:");
  17:  getch();
  18:  }

No comments:

Post a Comment