View Code of Problem 72

#include<stdio.h>
int main()
{
  int n,i;
  double m,h=0.0;
  scanf("%f" "%d",&m,&n);
  for(i=1;i<=n;i++){
    m=m/2;
    h=h+m+m/2;
  }
  printf("%.2f" "%.2f", m, n):
  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:11:3: warning: format '%f' expects argument of type 'double', but argument 3 has type 'int' [-Wformat=]
   printf("%.2f" "%.2f", m, n):
   ^
Main.c:11:30: error: expected ';' before ':' token
   printf("%.2f" "%.2f", m, n):
                              ^
*/

Double click to view unformatted code.


Back to problem 72