Tuesday, 17 April 2012

Get the value from user

Today we did some simple calculation with the values taken from the user
we have taken 2 numbers and then did the following calculations
1. Adding  2. subtracting 3. multiplication 4. divination
 Here is the code block

#include <stdio.h>
main()
{
    int i,j,result;
      printf("Write the two numbers you want to work with: " );
      scanf("%d %d", &i,&j);
      result= i+j;
      printf(" %d + %d = %d\n",i,j,result );  
      result = i-j;
      printf(" %d -  %d = %d\n",i,j,result ); 
      result = i*j;
      printf(" %d *  %d = %d\n",i,j,result ); 
      result = i/j;
      printf(" %d /  %d = %d\n",i,j,result );
      system("PAUSE");
      return 0; 
   }


Result window


No comments:

Post a Comment