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
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);
}
Answer:
The program is as:
#include<stdio.h>
#include<conio.h>
int main()
{
int m;
Printf("Enter a Number:");
scanf("%d",&m);
if(m>)
printf("n is ");
if(m==0)
printf("n is ");
if(m<0)
printf("n is ");
}
Output:
Enter a Number:
n is
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 . 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>)
printf("n is ");
if(m==0)
printf("n is ");
if(m<0)
printf("n is ");
}
Output:
Enter a Number:
n is
#SPJ3