The mentioned C program prints the natural numbers in a given range. The minimum and maximum value of the range ask by users.
#include<stdio.h>
int main()
{
int rangeMinValue,rangeMaxValue, i;
printf("Please Enter the rangeMinValue of natural number = ");
scanf("%d",&rangeMinValue);
printf("Please Enter the rangeMaxValue of natural number = ");
scanf("%d",&rangeMaxValue);
if((rangeMinValue > 0) && (rangeMaxValue > 0) && (rangeMaxValue > rangeMinValue ))
{
printf("List of Natural Numbers from %d to %d are \n",rangeMinValue,rangeMaxValue);
for(i = rangeMinValue; i <= rangeMaxValue; i++)
{
printf("%d ", i);
}
}
else
{
printf("Enter Valid numbers\n");
}
return 0;
}
Output:
Please Enter the rangeMinValue of natural number = 5
Please Enter the rangeMaxValue of natural number = 10
The mentioned C program prints the natural numbers in a given range. The minimum and maximum value of the range ask by users.
Output:
Please Enter the rangeMinValue of natural number = 5
Please Enter the rangeMaxValue of natural number = 10
List of Natural Numbers from 5 to 10 are
5 6 7 8 9 10
need an explanation for this answer? contact us directly to get an explanation for this answer