sami sam

sami sam

  • NA
  • 40
  • 29.4k

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

Aug 15 2012 7:39 AM
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)