Skip to content

Commit

Permalink
Create lab1
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanButt authored Jan 9, 2021
1 parent c04e503 commit d067fa9
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lab1
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;
}

0 comments on commit d067fa9

Please sign in to comment.