Write an algorithm to make an automated system which will help the builder to find the exact area for building the apartment
#include <stdio.h>
int count_ways(int n) {
if (n == 1) { return 4; }
int result;
int b=1, s=1, prev_b, prev_s;
for (int i = 2; i <= n; i++)
{
prev_b = b;
prev_s = s;
s = prev_b + prev_s;
b = prev_s;
}
result = s + b;
return result * result;
}
int main()
{
int n = 3;
scanf("%d", &n);
printf("Count of wats for %d sections is %d", n, count_ways(n));
return 0;
}
Comments
Leave a comment