program to display 10 multiples of a number

#include<stdio.h>
main()
{
	int m,n,o;
	m=5;
	
	for(n=0;n<11;n=n+1)
	
	o=m*n;
	
	printf("Multiples are %d",o);
}

Recommended Answers

All 6 Replies

So what's YOUR question?

Mine is "Why haven't you read the intro posts on how to use code tags?"

So what's YOUR question?
Mine is "Why haven't you read the intro posts on how to use code tags?"

Tricky question Salem; hard to answer. Could you make it a multiple choice one?

a) Because I am too busy to read any rule and beside, they are not that important.
b) Because I have a sense of entitlement and know my worth.
c) Because rules do not apply to me.
d) Because I am a newbie and people surely will have pity of me and cut me some slack.
e) All the above.

Do you mean this correction?

#include<stdio.h>
main()
{
[INDENT]int m,n,o;
m=5;

for(n=0;n<11;n=n+1)
{
[INDENT]o=m*n;
printf("Multiples of %d and %d are %d",m,n,o);[/INDENT]
}[/INDENT]
}

Do you mean this correction?

Nope, [s]he didn't mean that correction.
main() always returns an int as long as it is part of an operating system, therefore it should be int main ( void ) in this case, and care should put to finish the function with the statement return [status]. printf("Multiples of %d and %d are %d",m,n,o); You took the liberty of adding artifact to it, but not fix the ugly format that not including a '\n' at the end of the literal string in printf will originate.
Furthermore, if you choose to not carry return the cursor after each printf(), a call to fflush( stdout ) is a prudent statement to incorporate afterward.

it will show 11 multiples of a number NOT 10. Correct the for loop

it will show 11 multiples of a number NOT 10. Correct the for loop

If you are referring to the fact that the loop goes around eleven times, you are correct; nevertheless zero is not a multiple of any number. Therefore, it doesn't "show 11 multiples of a number".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.