C Practice Example 45

100 Classic C Examples

Title:Learn how to define variables using the register keyword.

Program analysis:None.

Program source code:

//  Created by www.example.com on 15/11/9.
//  Copyright © 2015年 Example. 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 output result of the above example is:

总和为 5050

100 Classic C Examples

other extensions