1 / 6

컴퓨터 프로그래밍 실습 6 4 월 11 일

컴퓨터 프로그래밍 실습 6 4 월 11 일. 문제 1) 사용자로부터 하나의 실수를 입력받아서 소수점 표기방법과 지수 표기 방법으로 동시에 출력하는 프로그램을 작성하시오 . < 힌트 > 지수형식지정자는 %e. 실수를 입력하시오 : 89.567 실수형식으로는 89.567000 입니다 . 지수형식으로는 8.956700e+001 입니다. #include < stdio.h > int main(void) { double data; printf (" 실수를 입력하시오 );

wattan
Download Presentation

컴퓨터 프로그래밍 실습 6 4 월 11 일

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 컴퓨터 프로그래밍실습 6 4월 11일

  2. 문제1) 사용자로부터 하나의 실수를 입력받아서 소수점 표기방법과 지수 표기 방법으로 동시에 출력하는 프로그램을 작성하시오.<힌트> 지수형식지정자는%e 실수를 입력하시오: 89.567 실수형식으로는 89.567000입니다. 지수형식으로는 8.956700e+001입니다. • #include <stdio.h> • int main(void) • { • double data; • printf("실수를 입력하시오); • scanf("%lf", &data); • printf("실수형식으로는 %f입니다\n", data); • printf("지수형식으로는 %e입니다\n", data); • return 0; • }

  3. 문제2) 사용자로부터 정수를 16진수로 입력받아서8진수, 10진수, 16진수 형태로 출력하는 프로그램을 작성하시오.<힌트> 16진수 형식지정자는%x 16진수 정수를 입력하시오: ff 8진수로는 0377입니다. 10진수로는 255입니다. 16진수로는 0xff입니다. • #include <stdio.h> • int main(void) • { • int data; • printf("16진수 정수를입력하시오); • scanf("%x", &data); • printf("8진수로는%#o입니다\n", data); • printf("10진수로는%d입니다\n", data); • printf("16진수로는%#x입니다\n", data); • return 0; • }

  4. 문제3) 우리나라에서 많이 사용되는 면적의 단위인 평을 제곱미터로 환산하는 프로그램을 작성하시오. 여기서 1평은 3.3m2이다. 변수들의 자료형은 어떤 것을 선택하는 것이 좋은가? 기호 상수를 이용하여 1평당 제곱미터를 나타내시오.<힌트> 기호 상수는 const double SQMETER_PER_PYEONG=3.3058; 와 같이 정의할 수 있다. # define SQMETER_PER_PYEONG=3.3058을 사용해도 된다. #include<stdio.h> int main(void) { const double SQMETER_PER_PYEONG=3.3058; double pyeong, m; printf("평을 입력하세요); scanf("%lf",&pyeong); m = pyeong*SQMETER_PER_PYEONG; printf("%lf평방미터입니다,m); return 0; } 평을 입력하세요: 30 99.174000 평방미터입니다.

  5. 문제4). 다음과 같이 화면에 출력하는 프로그램을 작성하시오.<힌트> “를 출력하려면 \“로,\를 출력하려면 \\ 로 한다. “ASCII code”, 'A', 'B', 'C‘, \t \a \n #include<stdio.h> int main(void) { printf("\"ASCII code\", 'A', 'B', 'C'\n"); printf("\\t \\a \\n\n"); return 0; }

  6. 문제5) 다음과 같이 문자를 저장하는 변수 한 개에 문자 `Z`를 저장한 후, 이 변수에 숫자를 더하거나 빼서 “I Love You"를 출력 하는 프로그램을 작성하시오.(대문자 ‘A’는 65, 소문자 ’a’는 97)

More Related