Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

write a c program to check wether a number is negative, positive ,or zero by if condition

0 votes
asked Jul 29, 2018 by anonymous
write a c program to check wether a number is negative, positive ,or zero by if condition

10 Answers

+1 vote
answered Jul 30, 2018 by Likitha Naidu (160 points)
#include<stdio.h>

int main()

{

int a;

printf("Enter number : ");

scanf("%d",&a); //scan the no.//

if(a>0)    //if no is positive//

{

printf("%d is positive",a);

}

else if(a<0)  //if no. is negative//

{

printf("%d is negative",a);

}

else   //remaining condition is zero only//

{

printf("%d is zero",a);

}

getch();

}

hope this help :D
0 votes
answered Aug 2, 2018 by Harish (140 points)

#include<stdio.h>

int main()

{

int a;

printf("Enter number : ");

scanf("%d",&a); 

if(a>0)    

{

printf("%d is positive",a);

}

else if(a<0)  

{

printf("%d is negative",a);

}

else 

{

printf("%d is zero",a);

}
return 0;

}

0 votes
answered Aug 2, 2018 by KirtiThakral19 (140 points)
#include<stdio.h>

#include<conio.h>

void main()

{

int a;

printf("enter the number");

sacnf("%d",&a);

if(a>0)

printf("number is positive");

else

if(a<0)

printf("number is negative");

else

if(a==0)

printf("zero");

getch();

}
0 votes
answered Aug 2, 2018 by Raju G (370 points)

#include<stdio.h>

int main()

{

int a;

printf("Enter number : ");

scanf("%d",&a); 

if(a>0)    

{

printf("%d is positive",a);

}

else if(a<0)  

{

printf("%d is negative",a);

}

else 

{

printf("%d is zero",a);

}
return 0;

}

0 votes
answered Aug 9, 2018 by anonymous

#include<stdio.h>

int main()

{

int a;

printf("Enter number : ");

scanf("%d",&a); 
 

}

카지노 

0 votes
answered Jan 17, 2020 by Niranjan Reddy C (180 points)
BY  USING CONDITIONAL OPERATOR

#include <stdio.h>
int main() {
    int num,x;
    printf("Enter a number: ");
    scanf("%d", &num);
    
  x=(num<0?printf("negative value"):(num==0?printf("you entered 0"):printf("Positive Number")));
  
}
0 votes
answered Jan 17, 2020 by Niranjan Reddy C (180 points)
#include <stdio.h>
int main() {
    int num;
    printf("Enter a number: ");
    scanf("%d", &num);
    if (num <= 0) {
        if (num == 0)
            printf("You entered 0");
        else
            printf("You entered negative number");
    } else
        printf("You entered positive number");
    return 0;
}
0 votes
answered Jan 20, 2020 by anonymous
#include <stdio.h>

void main(){

int a;

printf("Please enter a number: ");
scanf("%d", &a);

if(a > 0){
printf("Number entered is positive");
}

else if(a < 0){
printf("Number entered is negative");
}

else{
printf("Number entered is zero");
}

}
0 votes
answered Jan 20, 2020 by anonymous
#include <stdio.h>

void main()

{

int a;

printf("enter the number = ");

scanf("%d",&a);

if(a>0)

{

printf("the number is positive");

}

if(a<0)

{

printf("the number is negative");

}

else(a=0)

{

printf("the number is zero");

}

getch();

}
0 votes
answered Jan 21, 2020 by anonymous
#include<stdio.h>

int main()

{

int a;

printf("Enter a number=%d",a);

scanf("%d",&a);

if(a>0){

printf("The number is positive");

}

else if(a<0)

{

printf("The number is negative");

else if(a==0){

printf("The number is neither negative nor positive");

}

return 0;

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...