Menu
Coddy logo textTech

Inputs and Output

Part of the Fundamentals section of Coddy's Solidity journey. Lesson 6 of 53.

A function can receive values through named parameters. A parameter such as uint256 amount is a whole number that cannot be negative. Coddy supplies these values through the test arguments, in the order they appear in the main header. Solidity does not read keyboard input like a terminal program.

The statements in this excerpt run inside the provided main function.

uint256 amount = 14;
console.log(amount);
console.log("units");

Each console call adds a new output line. In the tasks, a header such as function main(uint256 amount) external view supplies amount instead of declaring a fixed value. Keep the supplied header; later lessons explain how to design functions and choose their modifiers.

Use the supplied parameter name to read an argument, and use separate console calls for separate output lines.

Tests can supply values through the parameters in your starter code. For example, this header gives the function an unsigned-integer parameter named amount:

function main(uint256 amount) external view {
    console.log(amount);
}

The tests choose the value of amount. Keep the supplied header and write your output statements inside its braces. Function declarations are covered in detail in the Functions chapter.

challenge icon

Challenge

Easy

Print the supplied count, then print items on the next line.

The tests pass arguments to main in this order: uint256 count. Each test starts with fresh contract state.

Use console.log for the requested output. Print only the requested values, one per line, with no extra labels unless the task specifies them.

Try it yourself

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import "forge-std/console.sol";
contract Main {
    function main(uint256 count) external view {
        // Write your solution here.
    }
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals

Practice on your own: Solidity playground