# Objective-C Variables and Indirection

Consider this small program that prints the numbers from one to five.

```#import <Foundation/Foundation.h>

int main (int argc, const char *argv[])
{
NSLog (@"The numbers from 1 to 5:");

for (int i = 1; i <= 5; i++) {
NSLog (@"%d\n", i);
}

return (0);

} // main

```

Now, suppose you want to upgrade your program to print the numbers from one to ten.

```#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
NSLog (@"The numbers from 1 to 10:");

for (int i = 1; i <= 10; i++) {
NSLog (@"%d\n", i);
}

return (0);

} // main

```

Now, the program is called Count-3 and looks like this:

```#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
int count = 5;

NSLog (@"The numbers from 1 to %d:", count);

for (int i = 1; i <= count; i++) {
NSLog (@"%d\n", i);
}

return (0);

} // main

```

If you want to print the numbers from 1 to 100, you just have to touch the code in one obvious place:

```#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{

int count = 100;

NSLog (@"The numbers from 1 to %d:", count);

for (int i = 1; i <= count; i++) {
NSLog (@"%d\n", i);
}

return (0);

} // main

```

By adding a variable, our code is now much cleaner and easier to extend, especially when other programmers need to change the code.

To change the loop values, they won't have to scrutinize every use of the number five to see if they need to modify it.

Instead, they can just change the count variable to get the result they want.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7938737,"math_prob":0.98084295,"size":1466,"snap":"2022-27-2022-33","text_gpt3_token_len":415,"char_repetition_ratio":0.14090288,"word_repetition_ratio":0.39781022,"special_character_ratio":0.34652114,"punctuation_ratio":0.17252396,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98938036,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-07-06T01:52:10Z\",\"WARC-Record-ID\":\"<urn:uuid:391c27af-e494-461c-a5e7-392b6f2c5d04>\",\"Content-Length\":\"9690\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:75eb8be6-eca3-43e2-b61e-cc65a143da6e>\",\"WARC-Concurrent-To\":\"<urn:uuid:e0b3fded-a5af-46ce-a188-ee4090085c0a>\",\"WARC-IP-Address\":\"52.85.151.82\",\"WARC-Target-URI\":\"https://www.demo2s.com/information-technologies/objective-c-variables-and-indirection.html\",\"WARC-Payload-Digest\":\"sha1:MV6BAGKXVXTWBUVJNXVKCDSDVE2Q3XEP\",\"WARC-Block-Digest\":\"sha1:3MNKNGBWTRL5JKNU5QPBLRTTSGTDP4RB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656104655865.86_warc_CC-MAIN-20220705235755-20220706025755-00284.warc.gz\"}"}