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


C-41: Simple Calculations

Elementary operations with small integers:

Refer Find Sum also.



#include<stdio.h>
#include<conio.h>
main()
      {
      clrscr();
      printf("\n\t\n\t");
      printf("x=%d,y=%d\n",x,y);
      z=x-y;
      printf("z=x-y=%d\n",z);
      z=x*y;
      printf("z=x*y=%d\n",z);
      z=x/y;
      printf("z=x/y=%d\n",z);
      z=y/x;
      printf("z=y/x=%d\n",z);
      z=x%y;
      printf("z=x%%y=%d\n",z);
      z=y%x;
      printf("z=y%%x=%d\n",z);
      getch();
      }



Output :x=5,y=7
z=x-y=-2

z=x*y=35
z=x/y=0
z=y/x=1
z=x%y=5
z=y%x=2
=========================================================================
Back to Home   &  C


C-40 : Check your Progress -1



Refer

  1.  My first C Program 
  2.  Example for Nested IF
  3. Example of Escape Sequence (\n)
Then , try to answer the following questions :

  1. Do you think comments can be nested , that is , can you have a comment with in a comment? Write a program with a nested comment and see if you can compile it.
  2. Write a C language program that gives for its output :    \* This is a C Comment*\
  3. Debug the following program :


#include<stdio.h>
#include<conio.h>
void main{}
(
            print("print this\m"\*very easy*\).
)

========================================================================
(Please use Comment section to post your answer).
===================================================================== === Back to Home   &  C