Friday, 6 July 2012

c program to find sum of two numbers (scanf,printf)

In this c program u need to input two numbers and program will give u the some
For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software). like Code::Blocks, dev c++  Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.}

sum of two numbers c program type

#include<stdio.h>
#include<conio.h>
main()
      int a,b,sum;
      printf("enter first number\n");
      scanf("%d",&a);
      printf("enter second number\n");
      scanf("%d",&b);
      sum=a+b;
      printf("the sum is %d",sum);
      getch();
      }

For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

output
output of program is
"enter first number
1
enter second number
2
the sum is 3

How?

1.int a,b,sum; it means value we are going to input is integer number
2.printf is for printing on screen
3.scanf is for input value from keyboard to a and b in the program

IS IT HELPFIL? comment.





1 comment:

  1. can you sent a code for " Read JPG image using C code"


    ?????/////

    ReplyDelete