#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
Chat with our AI personalities
Just as you would do it manually, I mean there is no predefined 'solve_equation' function in C.
If y = a + bi and z = c + di are two complex numbers then z - y = (c - a) + (d - b)i
sum = a + b + c;
Computer Concepts & Programming
C is a low level programming language or it is also called as machine level language as the code written in C is encrypted into machine readable form then it is executed. If you want to learn C programming language in depth then Newtum is a best option to start with. It's C programming online course provides complete knowledge of the all the basic concepts involved in programming. If you are interested, please vivist our website!