반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 모던자바스크립트
- Swift
- IOS
- algoritms
- 큐
- 백준
- 파이썬
- 알고리즘
- 혁신금융서비스
- BAEKJOON
- programmers
- 자바스크립트
- Ai
- Python
- JavaScript
- SSAFY
- React #Web #프런트엔드
- algorithms
- BFS
- 자료구조
- dfs
- MacOS
- 스택
- 일임형
- Algorithm
- 자문형
- frontend
- 신한투자증권
- 로보어드바이저
- JS
Archives
- Today
- Total
Step by Step
Objective-C 기본 개념 본문
반응형
변수 Objective-C에서는 데이터를 담을 수 있는 변수가 있다.
int amount = 10000;
printf("The amount in your account is $%i\n", amount);
프로그램을 실행하면 amount 변수의 값이 다음과 같이 저장된다.
#include <stdio.h>
int main(void){
int amount = 100000;
printf("The amount in your account is $%i\n", amount);
return 0;
}
변수 값 표시
변수에 저장된 값을 표시할 수 있는 printf() 함수는 매우 유용하다.
프로그램을 실행하면 amount 변수의 값이 다음과 같이 저장된다.
#include <stdio.h>
int main(void){
int amount = 100000;
printf("The amount in your account is $%i\n", amount);
return 0;
}
변수 값 표시
변수에 저장된 값을 표시할 수 있는 printf() 함수는 매우 유용하다.
데이터 타입
타입 | 설명 | 크기 |
char | 캐릭터 | 1바이트 |
double float | 더블형 정밀도 | 8바이트 |
float | 실수형 숫자 | 4바이트 |
int | 정수 | 4바이트 |
long | 더블 쇼트 | 4바이트 |
long long | 더블 롱 | 8바이트 |
short | 쇼트 정수 | 2바이트 |
Type 출력하기
#include <stdio.h>
int main (void)
{
int time = 4;
float temperature = 73.6;
printf("At %i 'o clock, Temperature is %4.1f degrees. \n",time, temperature);
return 0;
}
if 문
#include <stdio.h>
int main(void){
int tem = 77;
if (tem == 76){
printf("Perfet weather Today!\n");
}
else{
printf("Weather could be nice..\n");
}
return 0;
}
Switch문
#include <stdio.h>
int main(void){
int temperature = 73;
switch(temperature){
case 71:
printf("Could be a little warmer.\n");
break;
case 72:
printf("Perfect Weather.\n");
break;
case 73:
printf("It's a little warmer.\n");
break;
default:
printf("Unknown temperature.\n");
}
return 0;
}
조건 연산자
condition ? expression1 : expression2;
condition이 true면 expression1 이 되고 false면 expression2가 된다.
#include <stdio.h>
int main(void)
{
int t= 78;
t = t > 72 ? 72 : t;
printf("The temperature is %i. \n",t);
return 0;
}
for문
for(initialization; end_condition; after_loop_expression)
{
body
}
#include <stdio.h>
int main(void)
{
int loop_index;
for(loop_index = 0; loop_index < 5; loop_index++){
printf("You'll see this five times.\n");
}
return 0;
}
while문
#include <stdio.h>
int main(void){
int loop_index = 0;
while(loop_index<5){
printf("You'll see this five times,\n");
loop_index++;
}
return 0;
}
반응형
'ios 앱 개발' 카테고리의 다른 글
Delegate 패턴 (0) | 2025.03.26 |
---|---|
ViewController 간 Data 교환 (0) | 2025.03.26 |
Swift(Segueway 화면전환) (2) | 2025.03.26 |
Swift 기본문법(3) (1) | 2025.03.25 |
Swift 기본문법(2) 옵셔널 바인딩, 초기화 (0) | 2025.03.25 |