Print the Prime Number Divisible by 7 Using For Loop in C Programming


This program is written in the C programming language and is used to print all the numbers that are divisible by 7 between 1 and 100. The program starts by including the standard input/output library (stdio.h) and then defines a main function. Within the main function, the program declares three variables: "i", "n" and "a". The variable "n" is initialized to 7, and variable "a" is initialized to 100. The variable "i" is used as a loop counter in the program.

The program then uses the "printf" function to print a message "Numbers divisible by 7 are:" Next, the program uses a "for" loop with the counter variable "i" to iterate from 1 to the value of "a". Within this loop, it uses an if statement to check if the current value of "i" is divisible by 7. If the remainder of i divided by 7 is 0, it means that the number is divisible by 7.

If the number is divisible by 7, the program uses the "printf" function to print the number. Finally, the program returns 0 to indicate that the program has completed successfully. In this program, The loop will iterate 100 times and will check if a number is divisible by 7, if yes it will print that number.

Source Code

#include<stdio.h>
int main()
{
  int i,n=7,a=100;
  printf("Numbers divisible by 7 are:");
  for(i=1;i<=a;i++)
  {
    if(i%7==0)
    {
      printf("\n%d",i);
    }
  }
  return 0;
}
To download raw file Click Here

Output

Numbers divisible by 7 are:
7
14
21
28
35
42
49
56
63
70
77
84
91
98

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C