C PROGRAM TO FIND WHETHER THE GIVEN NO. IS POSITIVE OR NEGATIVE OR ZERO
C PROGRAM TO FIND WHETHER THE NUMBER IS POSITIVE OR NEGATIVE OR ZERO
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- clrscr();
- int a;
- printf("enter the number : "); /* get subscribed to my you tube channel
- scanf("%d",&a); for motivational , education ,
- if (a > 0) entertainment etc.*/
- printf("%d is a positive number "); LINK IS
- elseif (a == 0 )
- printf("%d is equals to zero ");
- else
- printf("%d is a negative number ");
- getch();
- }
OUTPUT:-
A.
enter the number : 5 SUBSCRIBE TO MY BLOG
5 is a positive number CPROGRAMMESEASY FOR MORE
C PROGRAMS LINK IS
B.
enter the number : -6
-6 is a negative number
C.
enter the number : 0
0 is equals to zero
EXPLANATION
FROM THE STARTING OF THE PROGRAM
1. FIRST WE HAVE HEADER FILES
2. THEN THE MAIN FUNCTION
3. NOW WE DECLARE THE VARIABLE , HERE WE USE A DATATYPE "INT" STANDS FOR INTEGER
4. NOW WE WANT A NUMBER FROM FROM THE USER WHICH HE WANTS TO DETERMINE WHETHER THE NUMBER IS POSITIVE OR NEGATIVE
5. AFTER TAKING INPUT , WE USE IF ELSE CONCEPT
6. THEN PRINT THE VALUES
7. AT END WE GIVE THE GETCH() COMMAND
PRECAUTIONS
- DON'T FORGET TO OPEN THE CURLIE BRACES
- DECLARE THE VARIABLES
- DON'T FORGET TO USE THE TERMINATORS
- CAREFULLY WRITE "PRINTF" BECAUSE MANY STUDENTS WRITE ONLY "PRINT"
- GETCH()
- CLOSE THE BRACKETS
Comments
Post a Comment