Favourite number in loop

Hi, I want to know how to "mark" the number as favourite number.
Let say I enter number 2, and the output will show 2 is the favourite number.
I only get to make the loop but not the favourite number part.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<stdio.h>
#include<stdlib.h>
#pragma warning (disable:4996)

main(void) {
	
	int i, n;

	printf("What is your favourite number (1 to 10)? ");
	scanf("%d", &n);
	
	for (i = 1; i <= 10; i+= 1)
	{
		printf("%d\n", i);
		

		
		
	}


	system("pause");
}

Do you mean something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int n = 0;

	printf("What is your favourite number (1 to 10)? ");
	scanf("%d", &n);

	for (int i = 1; i <= 10; ++i) {
		printf("%d", i);

		if (i == n)
			printf("  favorite number");

		puts("");
	}
}

Oh yeah, thank you so much!
Just a bit of defensive coding:

When using any of the scanf functions, always check the return value to see that it worked.
Topic archived. No new replies allowed.