+ 1
Can you explain addition program ?
10 Respostas
+ 6
can you provide more information? such as language and any sample code
+ 6
so c++.
ok.
#include <iostream>
int main () {
// we use int main () in standard c++, this is because most systems require a return value from the program to tell the operating system if the program executed correctly
int a, b, c;
// using cout, cin from iostream.
std::cout << "Enter a number: ";
std::cin >> a;
std::cout << "Enter another number: ";
std::cin >> b;
c = a + b;
std::cout << a << "+" << b << "=" << c << std::endl;
return 0;
}
here is a simple program that performs addition.
Some reading for you below.
https://www.sololearn.com/discuss/288609/?ref=app
+ 6
https://code.sololearn.com/ca5CVMwFF1t0/?ref=app
+ 6
which part is confusing in particular?
+ 3
at what language r u trying....
if u tell the language I can easily help u dude
+ 2
c language
+ 2
#include<stdio.h>
int main()
{
int a, b, c;
printf("Enter two numbers to add\n");
scanf("%d%d",&a,&b);
c = a + b;
printf("Sum of entered numbers = %d\n",c);
return 0;
}
+ 1
If you can optimize the code a bit by using only two variables.
Also try to make it more precise you are scanning both the variables together.
Also try to make the code more readable, instead of writing variable names like a,b,c you can use more readable terms.
which are standards of coding follow it from initial stage and it helps you lot further in future codes.
And heres the program code...
#include<stdio.h>
#include<conio.h>
int main(void)
{
int num1;
int num2;
printf("Enter the first number : ");
scanf ("%d", &num1);
printf("Enter the second number : ");
scanf ("%d", &num2);
printf("The addition of numbers = %d", num1 + num2 );
//Or you can simmply write the below statement as well...
printf("%d + %d = %d", num1, num2, num1 + num2 );
getch();
return 0;
}
0
#include <stdio.h>
#include <conio.h>
void main ()
}
int a,b,c;
0
it's look like...
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter the value of a and b");
scanf ("%d%d%". &a&b);
c=a+b;
printf(%d)
getch();
}