Mega Code Archive

 
Categories / C / Code Snippets
 

Use if else

#include <stdio.h> int main(void) { int x, y, op; printf("Enter first number: "); scanf("%d", &x); printf("Enter second number: "); scanf("%d", &y); printf("Enter 0 to add, 1 to multiply: "); scanf("%d", &op); if(op == 0) printf("%d", x + y ); else printf("%d", x * y ); return 0; }