Objective-c Study Notes (iv)--OC to achieve the simplest mathematical operations

Source: Internet
Author: User
Tags mul

This post implements the simplest subtraction operation using OC, which includes concepts such as variable definition, operation method, and formatted output. The main learning basic grammar, in fact, and the C language syntax is still more similar.

The exact code is just written in the main method. The detailed code is as follows:


#import <Foundation / Foundation.h>

int main (int argc, const char * argv []) {
     @autoreleasepool {
        
         int a = 4; // Define variables and assign values;
         int b = 2;
         int add = a + b; // addition operation;
         int sub = a-b; // Subtraction;
         int mul = a * b; // multiplication;
         int div = a / b; // divide;
         NSLog (@ "add =% d", add); // output the result;
         NSLog (@ "sub =% d", sub);
         NSLog (@ "mul =% d", mul);
         NSLog (@ "div =% d", div);
        
     }
     return 0;
} 

The final output results are as follows:



In conclusion, the best way for us to learn is to study the unknown knowledge according to the knowledge we have learned before, so as to Sichun and improve the learning efficiency.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Objective-c Study Notes (iv)--OC to achieve the simplest mathematical operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.