Sum of Numbers Divisible by 4 in C language
Write a Sum of Numbers Divisible by 4 in C program to calculate the sum of all numbers from 0 to 100 that are divisible by 4. Program should directly print the Sum of Numbers Divisible by 4 in C.
Sum of Numbers Divisible by 4 Program will simply start with 0 to 100 and check for numbers Divisible by 4.
Sum of Numbers Divisible by 4 C Code
#include<stdio.h> #include<conio.h> void main() { int i,sum=0; clrscr(); for(i=0;i<=100;i++) { if(i%4==0) sum=sum+i; } printf(“\naddition of numbers from 0 to 100 that are divisible by 4 is\n%d”,sum); getch(); }
Sum of Numbers Divisible by 4 Output Snapshot