What are Basics of Assigning Integer Variables (i, lo, hi and result) - Comprehensive Guide

Introduction

An integer variable is a type of data used to store and reference integer values, namely whole numbers (positive, negative or zero). Integer variables consist of four basic types: i, lo, hi, and result. This tutorial will teach you how to assign integer variables to each type and show you how to use them in your code.

i

The first integer variable is i. This is used to store and reference incrementing values from a loop or iteration. Whenever the loop or iteration increases, the value stored in i will follow suit. Here is an example of i  being put to use in a For Loop.

for (int i = 0; i < 10; i++) 
    Console.WriteLine("i = {0}"i);

This snippet will increment the value stored in i from 0 to 9 and then stops.

lo

The second integer variable is lo. This is used when you want to remember the lower boundary of a range or loop. Here is an example of lo being used in a For Loop.

for (int i = lo; i < 10; i++) 
    Console.WriteLine("i = {0}"i);

This snippet will set the lower boundary of the For Loop to whatever value is stored in lo and increments it until 10.

hi

The third integer variable is hi. This works much like lo in that it stores a boundary for a range, but for the upper boundary. Here is an example of how hi is used in a For Loop.

for (int i = 0; i < hi; i++) 
    Console.WriteLine("i = {0}"i);

This snippet will set the upper boundary of the For Loop to whatever value is stored in hi and increments it until the value is reached.

result

Finally, the fourth integer variable is result. This is used to store the results of your computation. It is the final result after the computation has been completed. Here is an example of how result is used when adding together two numbers.

int result = number1 + number2;
Console.WriteLine("The result is {0}"result);

This snippet will store the result of the addition in result and then output the final value.


FAQ

What is an integer variable?

An integer variable is a type of data used to store and reference integer values, namely whole numbers (positive, negative or zero).

How many types of integer variables are there?

There are four basic types of integer variables: i, lo, hi, and result.

What is 'i' used for?

i is used to store and reference incrementing values from a loop or iteration. Whenever the loop or iteration increases, the value stored in i will follow suit.

What is 'lo' used for?

lo is used when you want to remember the lower boundary of a range or loop.

What is 'hi' used for?

hi works much like lo in that it stores a boundary for a range, but for the upper boundary.

What is 'result' used for?

result is used to store the results of your computation. It is the final result after the computation has been completed.


Resources

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Lxadm.com.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.