Here is my code:
#include<iostream>
using namespace std;
int main(){
long long a, b, c;
cout<<"Vuvedete A:";
cin>>a;
cout<<"Sega vuvedi B:";
cin>>b;
c=a, a=b, b=c;
cout<<"A=";
cout<<a;
cout<<" B=";
cout<<b;
return 0;
}
#include<iostream>
using namespace std;
int main(){
long long a, b, c;
cout<<"Vuvedete A:";
cin>>a;
cout<<"Sega vuvedi B:";
cin>>b;
c=a, a=b, b=c;
cout<<"A=";
cout<<a;
cout<<" B=";
cout<<b;
return 0;
}
I knew its not in the right spot. Thank you! :)/>Moved to General.
Yep, It doesnt close or anything. But without codeblocks it closes.so in CodeBlocks this works fine? o.O
cout<<"A=";
cout<<a;
Can be this
cout << "A=" << a;
also there is a new line with
<< endl;
long long a, b, c;
And lastly it is good practise when having a main function to have the method declaration like this
int main( int argc, char* argv[] )
this allows runtime arguments, argc is the argument count and argv[] is an array of the argumentsThanks man, I'll add this.how are you running it outside of CodeBlocks?
Also as a side note thisCan be thiscout<<"A="; cout<<a;
also there is a new line withcout << "A=" << a;
<< endl;
Probably wouldn't have fixed the problem, (have a read of the edit too)…Thanks man, I'll add this.
Well CodeBlocks has "Build and run" I click that and it creates an .exe file of the program on my desktop and then I run it like a normal program (double click).Probably wouldn't have fixed the problem, (have a read of the edit too)…Thanks man, I'll add this.
So how are you running the code outside of CodeBlocks?
It does create it, however it closes it when it finishes printing to the window.it doesn't create a window for you to get input and display output (cin - console in, cout - console out)
Just tested again on mine and it does… haha wow, too long since I've done C++It does create it, however it closes it when it finishes printing to the window.
#include <iostream>
int main(void) {
int a, b;
std::cout << "Enter a value for a: ";
std::cin >> a;
std::cout << "Enter a value for b: ";
std::cin >> b;
int c = a;
a = b;
b = c;
std::cout << std::endl << "These are the new values:" << std::endl << "a = " << a << std::endl << "b = " << b << std::endl;
std::cin.get();
return 0;
}
Then why did you do it? :P/> Also, you didn't do it all for him, you barely added std::cin.get(); in there and beautified it a bit (like proper namespace usage). Besides that, it's exactly the same as in the OP. Give him some credit. :P/>I don't really like doing it all for you, if it's your homework, but this works: