C Language

May 27, 2023

how to use negative a number in c language

program to use negative a number in c language


#include<stdio.h>
int main()
{
    int num;
    printf("Enter a number : ");
     scanf("%d",&num);
     if(num<0)
     {
        printf("Number entered is negative\n");
        num=-num;
     }
     printf("value of num is : %d\n",num);
     return 0;
}

output


Enter a number : -4
Number entered is negative
value of num is : 4 

by : Ajaj Khan

Quick Summary:

इस program मैं दी गई संख्या positive है या negative है