Computer Science, asked by msanamicagupta, 10 months ago

Write a C program to read the value of an integer m and display the value of n is 1
when m is larger than 0, 0 when m is 0 and -1 when m is less than 0.

Answers

Answered by srisravan385
9

Explanation:

#include <stdio.h>

void main()

{

int m,n;

printf("Input the value of m :");

scanf("%d",&m);

if(m!=0)

if(m>0)

n=1;

else

n=-1;

else

n=0;

printf("The value of m = %d \n",m);

printf("The value of n = %d \n",n);

}

Answered by prakharuts015
1

Answer:

The program is as:

#include<stdio.h>

#include<conio.h>

int main()

{

   int m;

   Printf("Enter a Number:");

   scanf("%d",&m);

   if(m>0)

       printf("n is 1");

   if(m==0)

       printf("n is 0");

       if(m<0)

       printf("n is -1");

}

Output:

Enter a Number:

24

n is 1

Explanation:

C is a high-level and mainstream-purpose programming language that is ideal for come about firmware or portable requisition. in the first instance intended for writing system software, C was succeeded at Bell Labs by Dennis Ritchie for the Unix Operating System in the early 1970_S. C is a powerful mainstream-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on. C programming is an excellent language to learn to program for beginners. Our C tute will guide you to learn C programming one step at a time.

Hence, the correct answer is

The program is as:

#include<stdio.h>

#include<conio.h>

int main()

{

   int m;

   Printf("Enter a Number:");

   scanf("%d",&m);

   if(m>0)

       printf("n is 1");

   if(m==0)

       printf("n is 0");

       if(m<0)

       printf("n is -1");

}

Output:

Enter a Number:

24

n is 1

#SPJ3

Similar questions