-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main(void) | ||
{ | ||
int i,sum1=0,sum2=0,sum3=0; | ||
for(i=30;i<=1000;i++) { //for loop goes from 30 to 1000 and runs for all i less than or equal to 1000 | ||
if(i%4==0) // if numbeer is divisble by 4 it will be added to the sum | ||
{ | ||
sum1 += i; | ||
} | ||
} | ||
printf("%d",sum1); | ||
i = 30; | ||
while(i<=1000) { //while loop goes from 30 to 1000 and runs for all i less than or equal to 1000 | ||
i++; | ||
if(i%4==0) | ||
{ | ||
sum2 += i; | ||
} | ||
|
||
} | ||
printf("\n%d",sum2); | ||
i = 29; // i does not equal to 30 because we use a do while loop | ||
do //do while loop goes from 30 to 1000 and runs for all i less than or equal to 1000 | ||
{ | ||
i++; | ||
if(i%4==0) | ||
{ | ||
sum3 += i; | ||
} | ||
|
||
}while(i<=1000); | ||
printf("\n%d",sum3); | ||
|
||
|
||
return 0; | ||
} |