c grains of rice code example
Example: c grains of rice
#include <stdio.h>
#include <stdlib.h>
int main() {
long a, b = 1, c = 1, i = 0;
do
{
printf("Enter number of boxes: ");
scanf("%d", &a);
}while(a > 30);
a--;
for(i = 0; i < a; i++)
{
b = b * 2;
c = c + b;
}
printf("The number of grains is: %d\n\n\n", c);
system("pause");
}