0
Pls anyone help me to find mistake in my code its only printing if condition 1 nothing else
#include <stdio.h> int main() { int passed; printf("how many subjects have you passed"); scanf("%d",&passed); if(passed=2){ printf("you have passed in maths and science\n"); printf("your price is 45 ruppes\n"); } else if(passed=1){ printf("you have passed in 1 subject"); printf("your price is 15 ruppes"); } return 0; } https://code.sololearn.com/c9418mx4ZyGR/?ref=app
3 Answers
+ 1
Shayan Bhattacharjee
Because you are not comparing value in if case. You have used single equal (=) which is used to assign value.
Double equal (==) is used for comparison.
0
Shayan Bhattacharjee
Why did you share another person code. Is it necessary?
0
I didn't knew how to share post sorry for disturbing