Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Thursday, September 1, 2011

C-42 : Read values from keyboard for calculations

Read values from keyboard for calculations . And see how scanf() works.

Refer Simple Calculations also.



#include<stdio.h>
#include<conio.h>
main()
     {
      clrscr();
      int x,y,z;
      printf("Enter a value of x:");
      scanf("%d",&x);
      printf("Enter a value for y:");
      scanf("%d",&y);
      z=x*y;
      printf("z=x*y=%d\n",z);
      getch();
      return 0;
     }


Output :

Enter a value of x:
3Enter a value of y: 4
z=x*y=12
=========================================================================
Back to Home   &  C


No comments: