This is one ugly "C" code (I'm putting that into sarcastic quotes, because it's not really C by the standard). Please try to learn and understand the language better before teaching others, because it's just striking how can you make so many mistakes (and not even small ones) in such short piece of code and it doesn't even do what it says that it does and you're teaching something like that to others?! Also the code won't even compile under many sane compilers.
1) You're missing headers. Never omit headers, while some compilers might add them automatically, it's not standard behavior and it's poor practice to do. Write your code like a good programmer would.
2) Learn to indent your code, it's pain to read poorly formatted code.
3) main function is missing return type. Don't rely on defaulting to int, it's outdated. Keep up with the technology and slap "int" in front of it, otherwise it's not proper C according to latest standard. And bad programming practice in addition to that.
4)
Hidden Content
You must
[To see links please register here]
or
[To see links please register here]
to view this content.
What's the meaning of this? First, it's not standard C function and second and more importantly, why are you clearing the screen? Program shouldn't do something user doesn't expect it to do, you should use something like that only when it's crucial to the code, which it isn't, it's unnecessary clutter. Get rid of it. Fast.
5)
Hidden Content
You must
[To see links please register here]
or
[To see links please register here]
to view this content.
This bit is a bit pointless. You write n, which is a pointer to the first element of the array. Then you deference it with
to get the first element of the array and then you get its address with & to get the pointer to the first element of the array. Simply put, you need an apple, so you took apple, turned it to orange and then turned it to apple again. Why not just leave it apple?
Hidden Content
You must
[To see links please register here]
or
[To see links please register here]
to view this content.
6) What do you need the r pointer for? It's completely useless. Just use array indexing, you have the array right there, why do you have to print its contents in such overcomplicated way? Also "while" loop shouldn't be used here, if you know the number of repeats, always use for, it's a good programming practice to do it that way, which results in clean, readable and manageable code.
Hidden Content
You must
[To see links please register here]
or
[To see links please register here]
to view this content.
Simpler isn't it? Even faster and cleaner.
7) Okay... Ooookaaay... I don't get this. Why is a function which [i]multiplies called
show? Seriously why? Function should be called after what it does, not something else, because when I call function named show, I expect it to... well... show something, which yours doesn't. It's a horrible thing to do and sign of very bad code.
Remember: Always name functions, classes and variables after what they're do, give them meaningful names to make the code readable, understandable and more professional..
8) You declared the function show as returning int, but you don't return anything. Why? This code either won't compile, or it will return some garbage from the memory. In either way, it's not very good. Easiest thing is to make it void.
9) Same with main. You didn't specify type, which defaults to int with old versions of C, but again, you're not returning anything. Well it will return something if it compiles, but it won't be nice.
10) You're missing prototype of the function show. It won't compile with any normal compiler, because inside of main, it doesn't know about function show yet, so how can it reference it? Either put it in front of the main or put a prototype in front.
11) Learn to comment your code.
This is the example rewritten by me, with all the corrections:
Hidden Content
You must
[To see links please register here]
or
[To see links please register here]
to view this content.