fork download
  1. For finding floor((float)(a+c)/2), for large a,c
  2.  
  3. Let d= floor((float)(a+c)/2);
  4.  
  5. My approach
  6. ll int r=(a+c)%2;
  7. if(r==0||r==1)
  8. {
  9. d=(a+c)/2;
  10. }
  11. else if(r==-1)//for negative d
  12. {
  13. d=(a+c)/2-1;
  14. }
  15.  
  16. Alternative
  17. set d=(a+c)/2;
  18.  
  19. if(a+c<0)
  20. d--;
  21.  
  22. Both methods will calculate floor((float)(a+c)/2);
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:1: error: ‘For’ does not name a type
 For finding floor((float)(a+c)/2), for large a,c
 ^~~
prog.cpp:5:1: error: ‘My’ does not name a type
 My approach
 ^~
prog.cpp:7:1: error: expected unqualified-id before ‘if’
 if(r==0||r==1)
 ^~
prog.cpp:11:1: error: expected unqualified-id before ‘else’
 else if(r==-1)//for negative d
 ^~~~
prog.cpp:16:1: error: ‘Alternative’ does not name a type
 Alternative
 ^~~~~~~~~~~
prog.cpp:19:1: error: expected unqualified-id before ‘if’
 if(a+c<0)
 ^~
prog.cpp:22:1: error: ‘Both’ does not name a type
 Both methods will calculate floor((float)(a+c)/2);
 ^~~~
stdout
Standard output is empty