Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions solutions/c/difference-of-squares/1/difference_of_squares.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "difference_of_squares.h"

unsigned int sum_of_squares(unsigned int number)
{

unsigned int i = 1;
int multi = 0;
int b = 0;
while(i <= number)
{
multi = i * i;
b = b + multi;
i++;
}


return b;
}
unsigned int square_of_sum(unsigned int number)
{

unsigned int i = 1;
int sum = 0;
int multi = 0;
while(i <= number)
{

sum = sum + i;
i++;
}
multi = sum * sum;


return multi;

}

unsigned int difference_of_squares(unsigned int number)
{

unsigned int sum_squa = 0;
unsigned int squa_sum = 0;
unsigned int dif = 0;

sum_squa = sum_of_squares(number);
squa_sum = square_of_sum(number);

dif = squa_sum - sum_squa;
return dif;
}
8 changes: 8 additions & 0 deletions solutions/c/difference-of-squares/1/difference_of_squares.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef DIFFERENCE_OF_SQUARES_H
#define DIFFERENCE_OF_SQUARES_H

unsigned int sum_of_squares(unsigned int number);
unsigned int square_of_sum(unsigned int number);
unsigned int difference_of_squares(unsigned int number);

#endif