- 1

Could i write it like this ?

#include<iostream> using namespace std; main() { int a,b; a=10 b=10 int = a+b return 0; } without adding cout ? im completely new here!

15th Jun 2017, 12:17 PM
Noor Mohamed
Noor Mohamed - avatar
11 Respostas
+ 1
when u write int a,b; //it says to create two memory location of name a and b of the type integer. a=10; b=10; //it says to provide values 10 each to both the allocated memory. int c=a+b; // it says to create a new memory allocation of integer type named c AND perform a sum operation.. and place the output to the c.. return 0; mean u don't want the function to return any output.. if u write here.. return c; then the function will hold an output
15th Jun 2017, 12:27 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
you won't be able to see any output so cout is required.. wait there's error In it
15th Jun 2017, 12:18 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
oh tnx bud! you were right!
15th Jun 2017, 12:20 PM
Noor Mohamed
Noor Mohamed - avatar
+ 1
it would be like.. int main() { int a,b; a=10; b=10; int c= a+b; return 0; }
15th Jun 2017, 12:22 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
oh awesome...the above review really helped bruh!!! i followed you! do give me advice in my future comments !!!!
15th Jun 2017, 12:41 PM
Noor Mohamed
Noor Mohamed - avatar
+ 1
for sure.. and thanx ^_^
15th Jun 2017, 12:42 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
@Lival it isn't still correct. //it should be like this #include<iostream> using namespace std ; int main() { int a,b; a=10; b=10; int c= a+b; cout << c << endl; //endl isn't necessary but it's good to code like this return 0; } Now its correct :)
16th Jun 2017, 7:09 AM
blACk sh4d0w
blACk sh4d0w - avatar
0
sorry wait u missed semi colon and some syntax error
15th Jun 2017, 12:20 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
0
//it would be like.. #include<iostream> int main() { int a,b; a=10; b=10; int c= a+b; cout<<sum; return 0; } is this code correct ?
15th Jun 2017, 12:46 PM
Noor Mohamed
Noor Mohamed - avatar
0
no here 'sum' is not defined.. And one line is missing "using namespace std;" because the compiler don't find any memory allocated by variable "sum" and you know u have save it output in variable "int c" so the cout should be like cout<<c;
15th Jun 2017, 12:51 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
- 1
ahhh right! sorry im a complete newbie just started programmin 2 days ago
15th Jun 2017, 12:21 PM
Noor Mohamed
Noor Mohamed - avatar