Write a c program to print number from 1 to 100 which is divisible by 3 and 7 and both

Write a c program to print number from 1 to 100 which is divisible by 3 and 7 and both


#include<stdio.h>
int main(){
    int num,i;
    printf("Enter Number ");
    scanf("%d",&num);
    for (int i = 0; i < num; i++)
    {
      
        if (i%3==0)
        {
          
            printf("%d\n",i );
        }
        if(i%7==0){
            printf("%d\n",i );
        }
        if(i%3==0 && i%7==0){
            printf("%d\n",i );
        }
      

    }
    return 0;
}

Output
 
Previous
Next Post »

Disqus Shortname

Comments system