Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Exercise 45

C Exercise 45

100 Classic C Language Examples 100 Classic C Language Examples

**Problem:** Learn how to use register to define variables.

**Analysis:** None.

Program source code:



//  Created by www.runoob.com on 15/11/9.

//  Copyright © 2015 Runoob Tutorial. All rights reserved.

//



#include 

int main()

{

    register int i;

    int tmp=0;

    for(i=1;i<=100;i++)

        tmp+=i;

    printf("总和为 %d\n",tmp);

    return 0;

}

The output of the above example is:



总和为 5050

100 Classic C Language Examples 100 Classic C Language Examples