2022. 2. 9. 17:44ㆍ과제 업로드
#include <stdio.h>
int main()
{
int count = 10;
//단독사용
count++;
printf("단독사용(후위++)count = %d\n",count);
++count;
printf("단독사용(++전위)count = %d\n",count);
count--;
printf("단독사용(후위--)count = %d\n",count);
--count;
printf("단독사용(--전위)count = %d\n", count);
//대입연산자와 같이 사용 (변수는 result 사용)
int result = 0;
result = count++;
printf("대입 연산자와 같이 사용(후위++) result = %d, count = %d\n", result, count);
result = count--;
printf("대입 연산자와 같이 사용(후위--) result = %d, count = %d\n", result, count);
result = ++count;
printf("대입 연산자와 같이 사용(++전위) result = %d, count = %d\n", result, count);
result = --count;
printf("대입 연산자와 같이 사용(--전위) result = %d, count = %d\n", result, count);
//수식과 함께 사용할 경우
int total = 30;
count = 10;
result = --total + count++;
printf("result = %d, total = %d, count = %d\n", result, total, count);
result = ++total + count--;
printf("result = %d, total = %d, count = %d\n", result, total, count);
return 0;
}
'과제 업로드' 카테고리의 다른 글
2022.02.09 scanf문제 (0) | 2022.02.09 |
---|---|
2022.02.09 형식지정_제어문자 문제 (0) | 2022.02.09 |
2022.02.09 산술연산자문제(opExam_1) (0) | 2022.02.09 |
2022.02.08 While 문 문제 (0) | 2022.02.08 |
2022.02.07 단순 if_85 , switch~case 문제 (0) | 2022.02.07 |