Page 1 of 1

stack - tape calculator

Posted: Thu Jan 28, 2016 6:37 pm
by machinebacon
there is something called "tapecalc" in the repos, but I wanted something that does nothing else than adding input to a stack until terminated with C-c.

Code: Select all

#include<stdio.h>

float n,stack;

int main()
{
	for( ; ; ) {
	    printf("+ ");
	    scanf("%f",&n);
	    stack = n+stack;
	    printf("= %.1f\n", stack);
	}
	return 0;
}