0

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);
}
5
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by Aia
0

So what's YOUR question?

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

0

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.

0

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]
}
0

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.

0

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".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.