We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.

a very simple program and easy to understand that how to  Use array in function. reverse function will reverse the array 

#include<iostream.h>
const int row =3;

int read(int a[row]);
int display(int a[row]);
int reverse(int a[row]);

main(){
int a[row];
cout"User Input\n";
read(a);
cout"\nSame Values"endl;
display(a);

cout"\nRevered array\n";
reverse(a);
coutendl;
system("pause");
}
int read(int a[row]){
int i;

for(i=0; i<3; i++){
cout"\nEnter Number :";
cin>>a[i];

}

}
int display(int a[row]){
int i;
for(i=0; i<3; i++){
cout"\nNumber :"a[i][0];

}


}
int reverse(int a[row]){
int i;
for(i=3-1; i>=0; i--){
cout"\nRevered :"a[i];


}

}

if the given code doesn't work then download the .cpp file given below

Badshah

Views: 329

Attachments:

Replies to This Discussion

is code mn eight errors hn ,,plz chk it 

cout undeclared 

endl undeclared 

kia in sb ko main s phly declare krna ho ga???kesy?

 hifzah jab ning py code share kia jata hy to cout or cin k less then or greater then primary expression remove ho jaty hen wo lagao then execute ho ga or agr profect code chahiye to file b attach hy wo download kro  

and this is my humble request to Sir M.Tariq Malik that please fix this issue from new threads 

ni badsha m n jo file attach h us mn s hi kh rhi hn k errors hn 

plz chk again 

fixed  now check kren 

Attachments:

 abi b hn

hifzah bcz there iz no value wch functionz wll return.

hifzah  use return i; in all functionz. 

I correctd errorz;

Now check it;

#include<iostream>
using namespace std;
// badshah.hazor@gmail.com

const int row =3; // global variable
// declaration of function
int read(int a[row]);
int display(int a[row]);
int reverse(int a[row]);

int main(){
cout"\t\t***Badshah***\n\n";
int a[row];
cout"User Input\n";
read(a); // calling to a function
cout"\nSame Values"endl;
display(a);

cout"\nRevered array\n";
reverse(a);
coutendl;
system("pause");
}
// definations of functions
int read(int a[row]){
int i;

for(i=0; i<3; i++){
cout"\nEnter Number :";
cin>>a[i];

}
return i;

}
int display(int a[row]){
int i;
for(i=0; i<3; i++){
cout"\nNumber :"a[i];

}

return i;
}
int reverse(int a[row]){
int i;
for(i=3-1; i>=0; i--){
cout"\nRevered :"a[i];


}
return i;
}

Attachments:

an excellent girl you are

output;

ap ny kon c file attach ki hy yaha pr to show nai ho rahi again attach kro

RSS

Looking For Something? Search Below

Latest Activity

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service