This program is about to separate and print the positive or negative number up to limit using For Loop
#include<stdio.h> int main() { int i,n,pos,neg,s; printf("\nEnter the starting value:"); scanf("%d",&i); s=i; printf("\nEnter the ending value:"); scanf("%d",&n); printf("\nNegative numbers:"); for(i;i<=n;i++) { if(i<0) { printf("\n%d",i); neg++; } } i=s; printf("\nPositive numbers:"); for(i;i<=n;i++) { if(i>0) { printf("\n%d",i); pos++; } } printf("\nTotal number of positive:%d",pos); printf("\nTotal number of negative:%d",neg); return 0; }To download raw file Click Here
Enter the starting value: -5 Enter the ending value: 5 Negative numbers: -5 -4 -3 -2 -1 Positive numbers: 1 2 3 4 5 Total number of positive:5 Total number of negative:5
Learn All in Tamil © Designed & Developed By Tutor Joes