



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
introduction to C programming and exercises
Typology: Essays (university)
1 / 6
This page cannot be seen from the preview
Don't miss anything!




#include <stdio.h> int main(void) { int x, y, z; printf("3개의 정수를 입력하시오:"); scanf("%d %d %d", &x, &y, &z); printf("최대값:%d\n", (z > ((x > y)? x : y))? z : ((x > y)? x : y)); return 0; }
#include <stdio.h> int main(void) { int Z, ten, one; printf("정수를 입력하시오:"); scanf("%d", &Z);
ten = Z / 10; one = Z % 10; printf("십의 자리:%d\n일의 자리:%d\n", ten, one); return 0; }
/int형의 정수를 비트 연산자를 사용하여서 2 의 보수로 변환하는 프로그램/ #include <stdio.h> int main(void) { int N; printf("정수를 입력하시오:"); scanf("%d", &N); printf("2의 보수:%d\n", ~N+1); return 0; }
scanf("%d", &x); printf("y좌표를 입력하시오:"); scanf("%d", &y); (x > 0 && y > 0)? printf("1사분면\n") : printf(""); (x < 0 && y > 0)? printf("2사분면\n") : printf(""); (x < 0 && y < 0)? printf("3사분면\n") : printf(""); (x > 0 && y < 0)? printf("4사분면\n") : printf(""); return 0; }
/* 비트 이동 연산을 이용하여 문자 4 개를 받아서 하나의 unsigned int형의 변수 안에 저장 하는 프로그램*/ #include <stdio.h> int main(void) { unsigned int result; char x0, x1, x2, x3; printf("첫번째 문자:"); scanf("%c", &x0); printf("두번째 문자:"); scanf("%c\n", &x1); printf("세번째 문자:"); scanf("%c\n", &x2);
printf("네번째 문자:"); scanf("%c\n", &x3); result = (result | x0); result = (result << 8); result = (result | x1); result = (result << 8); result = (result | x2); result = (result << 8); result = (result | x3); printf("결과값:%x\n", result); return 0; }