Last active
September 12, 2019 07:43
-
-
Save sumukus/dc9aed0f79f60cec7eb5b0e856120eaa to your computer and use it in GitHub Desktop.
This is script file containing the c++ program code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int sortArray(int[],int); | |
int main(){ | |
int mark[]={9,3,5,6,1,5,4,7,1}; | |
int size=sizeof(mark)/sizeof(int); | |
sortArray(mark,size); | |
return 0; | |
} | |
int sortArray(int mark[],int size){ | |
for(int i=0;i<size;i++){ | |
int temp=0; | |
for(int j=0;j<size-1;j++){ | |
if(mark[j] < mark[j+1]){ | |
temp=mark[j]; | |
mark[j]=mark[j+1]; | |
mark[j+1]=temp; | |
} | |
} | |
} | |
for(int k=0;k<size;k++){ | |
cout << mark[k]<<" "; | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int main(){ | |
int a=2,b=3; | |
cout << "Before swap value of a:" <<a<<" and b:"<<b<<"\n"; | |
int temp=a; | |
a=b; | |
b=temp; | |
cout << "After swap value of a:"<<a<<" and b:"<<b<<"\n"; | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
//Function declaration/prototype | |
void swapFunction(int *, int *); | |
//Call by Reference Example | |
int main(){ | |
int a=2,b=3; | |
cout << "Before swap value of a:" <<a<<" and b:"<<b<<"\n"; | |
//Function Calling | |
swapFunction(&a,&b); | |
return 0; | |
} | |
//Function definition | |
void swapFunction(int *a, int *b){ | |
int temp=*a; | |
*a=*b; | |
*b=temp; | |
cout << "After swap value of a:"<<*a<<" and b:"<<*b<<"\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
void swapValue(int,int); | |
//Call by Value Example | |
int main(){ | |
int a=2,b=3; | |
cout << "Before swap value of a:" <<a<<" and b:"<<b<<"\n"; | |
swapValue(a,b); | |
return 0; | |
} | |
void swapValue(int x,int y){ | |
int temp; | |
temp=x; | |
x=y; | |
y=temp; | |
cout << "After swap value of a:"<<x<<" and b:"<<y<<"\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment