E D R , A S I H C RSS

간단한C언어문제

한 C .
C ** .
** : .


~cpp 
Spec  .
16Bit  Windows
ANSI C  Compiler (C90)

, .

1.
~cpp 
#include <stdio.h>

main(){
int i;

	for(i=0; i<10; i++){	//  : { for    . -_-.      .(.)
		printf("%d", i);
	}
}
Note:
-
. -_- -

. . -yahar

. -

C ;;; return형 int형 warnning ;; -
. C90 . , .
, . -yuhar
-

2.
~cpp 
#include <stdio.h>

main(){
int a, b;
double c;

	a = 30000;
	b = 30000;

	c = a + b;

	printf("%f", c);
}
Note:
-
. %f %d .-
signed int형 a b (65535/2) - . (-65536/2)+((30000+30000)-(65536/2-1)) <- 제대로 설명을 못하겠다;;; -
-

3.
~cpp 
#include <stdio.h>

main(){
const char *a;
char *b, msg[]="test code";

	a = msg;
	b = a;

	puts(msg);
	puts(msg);
}
Note:
-
. &a (;;)-
. b=a; . const char *형 char *형 . . -
-

4.
~cpp 
//     ,  .
#include <stdio.h>

main(){
float num;
char data[]="123.12";

	num = atof(data);

	printf("%f", num);
}
Note:
-
. f s. -
. atof함 float , atof함 int형 return. , num 123 . ANSI C99 . -
-

5.
~cpp 
main(){
int a, b, c;

	a = 0010;
	b = 0200;
	c = 2000;

	printf("a=%d b=%d c=%dn", a, b, c);
}
Note:
-
. 0 . -
. 0 8 . 0x <- 16진수 -
-

6.
~cpp 
#include <stdio.h>
#include <ctype.h>

main(){
char ss[] = "A2 ";
int i;

	puts(ss);

	for(i=0; ss[i]; i++){
		printf("i=%d %4x(%4d) ", i, ss[i], ss[i]);
		if(isdigit(ss[i]))	puts("");
		else			puts(" ");
	}
}
Note:
-
. ss[] "" isdigit . (확.) isdigit unsigned char형 . char형 signed형. -
-

7.
~cpp 
#include <stdio.h>

main(){
int i;

	while(scanf("%d", &i), i)
		printf("%d", i);
}
Note:
-
. . -
. , . -
-

8.
~cpp 
#include <stdio.h>

main(){
char *p;

	gets(p);
	puts(p);
}
Note:
-
. 히 포 . -
. 포 . -
-

9.
~cpp 
// main.h
#define NUM 100

struct a {
	int num1;
	int num2;
};

// main.c
#include "main.h"
#define NUM 200

main(){
struct a test;

	test.num1 = 100;
	test.num2 = 200;

	printf("%d", test.num1+test.num2);
}
Note:
-
. -
. NUM 2 define . define 200 . -
-

10.
~cpp 
//   linking
//main1.c
static int a = 100;

int mul(int num)
{
	printf("a = %d", a);
	return num*num;
}

//main2.c
main(){
exturn int a;

	printf("a = %d");
	printf("%d", mul(100));
}
Note:
-
. -
. static C++ private . 한 파 . -
-

11.
~cpp 
//   linking
// 1.c
main(){
double a, b;

	a = 1234.1234;
	b = 123.123;

	printf("%f", mul(a, b));
}

// 2.c
double mul(double a, double b){
	return a*b;
}
Note:
-
. -
. 함 return형 int형 . return . -
-

12.
~cpp 
main(){

Note:
-
-

100 . -_-
11 .

? --
. --
. ^^ ㅋㅋ --
. . --

. -

;; -

----

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:38
Processing time 0.0239 sec