Computer Science, asked by abbaskhan79, 2 months ago


What is the difference a constant and variable? Also write a Basic language program to input any number, if number is greater than zero, then
display "positive number otherwise display "Negative number".​

Answers

Answered by MrsZiddi
2

In the following program we are checking whether the input integer number is positive or negative. If the input number is greater than zero then its positive else it is a negative number. If the number is zero then it is neither positive nor negative. Same logic we have followed in the below C program.

/* Description: A program to check whether the input

* integer number is positive or negative.

* Written by: Chaitanya Singh

* Published on: beginnersbook.com

*/

#include <stdio.h>

void main()

{

int num;

printf("Enter a number: \n");

scanf("%d", &num);

if (num > 0)

printf("%d is a positive number \n", num);

else if (num < 0)

printf("%d is a negative number \n", num);

else

printf("0 is neither positive nor negative");

}

Output 1:

Enter a number:

0

0 is neither positive nor negative

Output 2:

Enter a number:

-3

-3 is a negative number

Output 3:

Answered by aditya95250
0

Answer:

A constant does not change its value over time. A variable, on the other hand, changes its value dependent on the equation. ... Constants usually represent the known values in an equation, expression or in line of programming.

Similar questions