I am 11 years old and I have just started to learn C++ and I really don't know much about it. I was making a small program to calculate the area and circumference of the circle. I wanted to give user the option to choose which one they want to calculate. So I typed the following command.....
#include<iostream>
#include<conio.h>
int main()
{
 float r;
 float area;
 float cir;
 char n;
 std::cout<<"If you want to calculate the circumference of the circle, type 1 OR if you want to calculate the area, type 2: ";
 std::cin>>n;
 if(n=1)
 {
     std::cout<<"Enter the radius of the circle: ";
     std::cin>>r;
     cir=2*3.14*r;
     std::cout<<"The circumference of the circle is: "<<cir;
     getch();
     return 0;
 }
 if(n=2)
 {
     std::cout<<"Enter the radius of the circle: ";
     std::cin>>r;
     area=3.14*r*r;
     std::cout<<"The area of the circle is: "<<area;
     getch();
     return 0;
 }
}
I compiled it and it showed no errors. But when I ran it, it only calculated the circumference no matter what I type. Any help will be appreciated.