#include <stdio.h>
int mul(int first, int second){
    int prod;
    prod= first * second;
    return prod;
}
void main(void){
    int i, j, result, *q;
    int a[6]={2,3,4,5,6,7};
    q=a;  //q=a의 첫번째 원소 2
    for(i=0; i<5; i++){  //i=0~4
        j=i+1;           //j=1~5
        result=mul(*(q+i), *(q+j)); 
        //i=0일 때, *(q), *(q+1)의 곱=2*3=6
        //i=0, j=1, *(q)=2, *(q+1)=3  출력!!
        //result=6  20보다 작음
        //i=1일 때, *(q+1), *(q+2)의 곱=3*4=12
        //i=1, j=2, *(q+1)=3, *(q+2)=4  출력!!
        //result=12   20보다 작음
        //i=2일 때, *(q+2)=4, *(q+3)=5의 곱=4*5=20
        //i=2, j=3, *(q+2)=4, *(q+3)=5  출력!!
        //result=20 20과 같으면 break
        printf("%d %d %d %d\n", i, j, *(q+i), *(q+j));  //ㄱ
        if(result>=20) break;
    }
    printf("Result: %d\n", result); //ㄴ
    //Result: 20 출력
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: