Where arguments are written in c++ pogram | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Where arguments are written in c++ pogram

12th Oct 2016, 1:25 PM
Mehul Kalal
Mehul Kalal - avatar
4 Answers
+ 1
Arguments are function parameters. They are put between parenthesis right after the function name. For example: int square(int n) { return n*n; } Here the function square takes one integer argument that it names n. When calling square(42), I pass 42 to the function as parameter. If you meant to ask how to use parameters for the program itself, use the int main(int argc, char* argv[]) prototype, where argc is the number of arguments (including the program itself as first parameter) and argv an array of arguments. Here is an example: int main(int argc, char* argv[]) { int i; for (i = 0; i < argc; i++) { cout << argv[i] << endl; } }
12th Oct 2016, 1:55 PM
Zen
Zen - avatar
0
You Can Use Arguments In Writing Function. Example : int add(int a ,int b); Here The int a and int b are The Arguments.
12th Oct 2016, 1:47 PM
PIYUSH KUMAR
0
ty Piyush Kumar
12th Oct 2016, 1:49 PM
Mehul Kalal
Mehul Kalal - avatar
0
Arguments are used on defining and calling the functions
13th Oct 2016, 11:33 AM
rahul sharma
rahul sharma - avatar