+ 1

Can you explain addition program ?

22nd Sep 2017, 7:25 AM
Syed Ubaid Zaidi
10 Respostas
+ 6
can you provide more information? such as language and any sample code
22nd Sep 2017, 8:23 AM
jay
jay - avatar
+ 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
22nd Sep 2017, 8:37 AM
jay
jay - avatar
+ 6
https://code.sololearn.com/ca5CVMwFF1t0/?ref=app
22nd Sep 2017, 8:39 AM
jay
jay - avatar
+ 6
which part is confusing in particular?
22nd Sep 2017, 9:50 AM
jay
jay - avatar
+ 3
at what language r u trying.... if u tell the language I can easily help u dude
22nd Sep 2017, 9:17 AM
Mac
Mac - avatar
+ 2
c language
22nd Sep 2017, 9:18 AM
Syed Ubaid Zaidi
+ 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; }
22nd Sep 2017, 9:23 AM
Syed Ubaid Zaidi
+ 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; }
22nd Sep 2017, 4:54 PM
Abhishek Lokare
Abhishek Lokare - avatar
0
#include <stdio.h> #include <conio.h> void main () } int a,b,c;
22nd Sep 2017, 8:28 AM
Syed Ubaid Zaidi
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(); }
22nd Sep 2017, 9:17 AM
Syed Ubaid Zaidi