1
Answer

I need help for using if and else functions in C Programming.

sami sam

sami sam

12y
1.1k
1
I am sure this program is ok but and dose not WORK.


#include <stdio.h>
int main (){
int x,y,z;
printf("please enter value of x");
scanf("%d",&x);
printf("please enter value of y");
scanf("%d",&y);
if (y == 0) {
printf("You can not divide by zero");}
else{
z = x / y;
printf("divide = %d \n",z);}

and also 

#include <stdio.h>
int main (){
int x,y,z;
printf("please enter value of x");
scanf("%d",&x);
printf("please enter value of y");
scanf("%d",&y);
if (y != 0) {
z = x / y;
printf("Divide = %d \n",z);
}
else{
printf("You can not divide by zero");
}
Answers (1)
Next Recommended Forum