#include <stdio.h> int func(){ int i; while(1) { printf("input plus integer = "); scanf("%d",&i); if(i>0) { printf("ok\n"); return i; } };} int surplusPower(int b,int e,int m){ int r=b%m; while(--e) r=(r*b)%m; return r;} int main(){ printf("result = %d\n",surplusPower(func(),func(),func())); return 0;}
-2 0 123 0 -11 456 -23 0 789
input plus integer = input plus integer = input plus integer = ok input plus integer = input plus integer = input plus integer = ok input plus integer = input plus integer = input plus integer = ok result = 51
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!