For eg. If you want to print the multiples of 3 within a limit, you will just have to change the datatype of the variables into float and change the if condition into (i % 3 == 0).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int a,b,i; | |
printf("Enter the starting number: "); | |
scanf("%d",&a); | |
i=a; | |
printf("Enter the limit: "); | |
scanf("%d",&b); | |
while(i>=a && i<=b) | |
{ | |
if((i%2)==0) | |
{ | |
printf("\t%d",i); | |
} | |
i=i+1; | |
} | |
getch(); | |
return(0); | |
} |
Comments
Post a Comment