Latest web development tutorials

C Exercise Example 45

100 cases of classic C language 100 cases of classic C language

Title: learning to use the register to define variables.

Program Analysis: None.

Source Code:

//  Created by www.w3big.com on 15/11/9.
//  Copyright © 2015年 本教程. All rights reserved.
//

#include <stdio.h>
int main()
{
    register int i;
    int tmp=0;
    for(i=1;i<=100;i++)
        tmp+=i;
    printf("总和为 %d\n",tmp);
    return 0;
}

The above example output is:

总和为 5050

100 cases of classic C language 100 cases of classic C language