answersLogoWhite

0


Best Answer

#include <stdio.h>

#include <conio.h>

int main()

{

int x;

int y;

int result;

printf("Enter the first number to be added: ");

scanf("%d",&x);

printf("Enter the second number to be added: ");

scanf("%d",&y);

result = x + y;

printf("Here is the result %d\n",result);

return(0);

getch();

}

Heres the low down:

1) The #include <stdio.h> includes the file stdio.h into your code so it knows what the functions such as printf() mean.

2) int main() is the main function you write most of your code in.

3) int x; , int y; , and int result. the int stands for integer or a number (no decimal points you need a float for that) the X and Y are the numbers you are adding together and result is the result of the numbers.

4) printf("Enter the first number to be added: ");

scanf("%d",&x); the Printf() prints the text, Enter the first number to be added: , onto the screen and the scanf("%d",&x); looks for the number input from the keyboard for x.

5) printf("Enter the second number to be added: ");

scanf("%d",&y); does pretty much the same as the last 2 lines except it looks for the value for y instead of x.

6) result = x + y; that adds the values of X and Y and stores the result in the variable result.

7) printf("Here is the result %d\n",result);

return(0); that prints the result on the screen and the return(0); tells the OS that the program ended successfully.

Hope this helps,

Mr. Man

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C programming for adding two numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

C plus plus programming for addition of two numbers?

int main() { int x = 40 + 2; }


What are the two major types of programming languages in c plus plus?

Object oriented programming and structured programming.


What programming languages use a C switch statement?

There are two programming languages which use a C switch statement. The two languages are C and C++, hence the name C switch statement. There may be more, but those are the most obvious ones


What is c program to calculate product of all even numbers from entered number down to 1?

c is programming laungage


What are two types of programming languages?

C++, Perl, Fortran


What is meant by for loop in C programming?

loops execute a set of insructions repeatedly for a certain numbers of times..


What is the memcpy library used for in computer programming?

The memcpy library is used in computer programming to copy the value of numbers from a source to the memory block destination. Memcpy is frequently used in the C++ programming language.


What is c and c in computer programming?

C and C++ are both high-level programming languages.


Create a spiral in C programming?

create spiral in c programming?


How do you reinstall c?

Your question makes no sense, you cannot "reinstall" programming languages (or vitamines, or letters, or Roman numbers)


What has the author Robert Lafore written?

Robert Lafore has written: 'Object-oriented programming in Microsoft C++' -- subject(s): Object-oriented programming (Computer science), C++ (Computer program language), C. 'Microsoft C. Programming for the I.B.M.Personal Computer' 'Object-oriented programming in C++' 'Windows Programming Made Ridiculously Easy Book' 'The Waite Group's C Programming Using Turbo C++ (The Waite Group)' 'Microsoft C programming for the IBM' 'The Waite Group's Microsoft C programming for the PC' -- subject(s): C (Computer program language), IBM microcomputers, Microsoft C (Computer program), Microsoft C., Programming


When was C - programming language - created?

C - programming language - was created in 1972.