What is an argument in programming?

iD Tech in action

Argument definition

An argument is a way for you to provide more information to a function. The function can then use that information as it runs, like a variable. Said differently, when you create a function, you can pass in data in the form of an argument, also called a parameter. 

  • Arguments are variables used only in that specific function. 
  • You specify the value of an argument when you call the function.
  • Function arguments allow your programs to utilize more information.

C++ argument example

Say you want to create a function that describes how much fun you're having; you'd want to be able to use different words to be as descriptive as possible.

Before now, the function may have looked like:

 string howMuchFun() {
     return "so much fun";

But then you'd always have the same amount of fun, never any more!

You can use arguments to change how much fun your function will say you're having.

Using arguments

1. Modify the function prototype and implementation to take a string argument:
 string howMuchFun(string amount); 

2. Change your return statement to:
 return amount + " fun"; 

3. Add a string to the parentheses where you call the function:
 howMuchFun("tons of") 

Adding arguments can really expand how much they can do! You can add even more arguments by using commas between each argument (string amount, string noun).

A photo of Ryan

Ryan has been in EdTech and with iD Tech for 13 years—building experience, expertise, and knowledge in all things coding, game development, college prep, STEM, and more. He earned his MBA from Santa Clara University after obtaining his Bachelor’s degree from Arizona State. Connect on LinkedIn

Featured Posts



About iD Tech

iD Tech is the #1 tech camp on the planet, and world leader in youth STEM education, with programs held online and at 75+ global locations offering 50+ innovative tech courses: 

Coding camps
Video game camps
Robotics classes & camps
Creative arts classes & camps
All STEM camps

We've bet our reputation on recruiting the top instructors in the country. Our small classes ensure customized learning, leading to "a-ha moments" and awesome outcomes. Programs include:

On-Campus Programs

Online Tutoring

All Coding Courses