View Code of Problem 72

#include<stdio.h>
void main(){
   double M,N,sum=0,i;
   scanf("lf% %lf",&M,&N);
   sum=M;
   for(i=1;i<n;i++){
     M=M/2.0;
     sum=+M;
     if(i>0)
       sum+=M;
     if(i==n)
       M=M/2;
     
  }
	printf("%.2lf %.2lf\n",M,sum);
}
/*
Main.c:2:6: warning: return type of 'main' is not 'int' [-Wmain]
 void main(){
      ^
Main.c: In function 'main':
Main.c:4:4: warning: unknown conversion type character 0x20 in format [-Wformat=]
    scanf("lf% %lf",&M,&N);
    ^
Main.c:4:4: warning: too many arguments for format [-Wformat-extra-args]
Main.c:6:14: error: 'n' undeclared (first use in this function)
    for(i=1;i<n;i++){
              ^
Main.c:6:14: note: each undeclared identifier is reported only once for each function it appears in
*/

Double click to view unformatted code.


Back to problem 72