View Code of Problem 72

#include<stdio.h>
int main()
{
  int N,i;
  double M,h;
  scanf("%f" "%d",&M,&N);
  for(i=1;i<=N;i++){
    m=m/2;
    h+=m+m/2;
  }
  h=h-m;
  printf("%.2f" "%.2f",m,h):
  return 0;
}
/*
Main.c: In function 'main':
Main.c:6:3: warning: format '%f' expects argument of type 'float *', but argument 2 has type 'double *' [-Wformat=]
   scanf("%f" "%d",&M,&N);
   ^
Main.c:8:5: error: 'm' undeclared (first use in this function)
     m=m/2;
     ^
Main.c:8:5: note: each undeclared identifier is reported only once for each function it appears in
Main.c:12:28: error: expected ';' before ':' token
   printf("%.2f" "%.2f",m,h):
                            ^
*/

Double click to view unformatted code.


Back to problem 72