0
Can anyone please tell where I am doing mistake in my code but still I am getting error while my execution time
#include<iostream> using namespace std; //fuction declartion void swap(int x,int y); int main() { //local variable declartion int a =100; int b=200; cout<<"before swap value of a:"<<a<<endl; cout<<"before swap value of b is:"<<b<<endl; // calling a function to swap the values swap(a,b); cout<<"after swap value of a:"<<a<<endl; cout<<"after swap value of b is:"<<b<<endl; return 0; }
8 Réponses
+ 3
A) You use the built-in swap function. Then don't redeclare it in the head of the script.
B) You meant to write an own swap function. Then the declaration is missing.
+ 1
Remove
void swap(int x, int y);
in order to use the built-in function
0
I do not see where you are adding any logic to the swap function. You're just passing in parameters.
0
Were is the function defined?
Please LINK your complete code:
Go to Code section, click +, select the programming language, insert your code and save.
Come back to this thread, click +, Insert Code, sort for My Code Bits, select your code.
0
I did everything bro this is my whole code but I am not getting output swapping values of a and b if you know about some functions where I am doing mistake please tell me
0
But I did point something out. I said that you're only passing in parameters, but you're not doing anything with the parameters that you're taking in.
You need to tell the computer what you want to do with the parameters that you're passing in. It can't read your mind and doesn't know what "swap" means yet until you give it clear instructions.
0
I am not getting your point can you write it down in the text maybe I understand better
0
Okay thnx