• Source
    1. #import <objc/objc.h>
    2. #import <objc/Object.h>
    3. #import <Foundation/Foundation.h>
    4.  
    5. @interface TestObj : Object
    6. {
    7. //none
    8. }
    9. - (void)testMethod;
    10. @end
    11.  
    12. @implementation TestObj
    13. - (void)testMethod {
    14. //declare two float variables
    15. float var1,var2;
    16.  
    17. //scanf("%f,%f",var1,var2);
    18. //assumption
    19. //var1=1.0; var2=0.0;
    20. var1=1.0; var2=2.0;
    21.  
    22. if (var2==0){
    23. //error
    24. printf("%s","Error. Division by zero.");
    25. }
    26. else {
    27. //printing a formatted output of the result of dividing float value
    28. printf("%f", (var1 / var2));
    29. }
    30. }
    31.  
    32. int main()
    33. {
    34. id obj = [[TestObj alloc] init];
    35. [obj testMethod];
    36. return 0;
    37. }
    38. @end