Run into some problem looping

Hello. So, I'm new to C and I'm currently trying some new code with C. However, I stumbled upon a problem with this code. I tried to do a selection loop where the code will print either pen or paper, but it only print pen no matter what value I entered. Is there something wrong with my code?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  #include <stdio.h>

void menu_selection();//declare user-define function
void pen();
void paper();

int main() //main function

{


printf("                     KFC                      \n");
printf("----------'Welcome my dear customer'----------\n\n");

menu_selection();

    return 0;
}

void menu_selection()

{
    int mains;
    

printf("Select your main menu:\n");
printf("1.pen\n");
printf("2.paper\n\n");


scanf("%d",&mains);

if(mains=1)
{ 
    pen();
}
else if(mains=2)
{
    paper();
}

else 
    menu_selection();
    

}
    
void pen()
{
    printf("pen\n");
    

}

void paper()
{
    printf("paper\n");
    
}

= assignment
== comparison
line 33,37: You're using the assignment operator (=), not the comparison operator (==).
Oh lol. I see.... Thanks guys.... I'm totally noob when it comes to these kind of stuff....
Topic archived. No new replies allowed.