Raspberry Pi_Eng_23.6.2 Writing C language Program


Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


23.6.2  Writing Program

 

A typical C program usually has the following format. Header file is specified in the first line of the program. And "main" function corresponds to the body of the program.

 

#include <stdio.h>

 

 

int main(void)

{

 

 

}

 

Here we will use a simple program that takes number input, calculates it, and then displays the result on the screen. We will write and use the following simple program code.

 

#include <stdio.h>

 

int main(void)

{

        int i = 0;

        printf("Hello. input your number \n");

        fscanf(stdin,"%d", &i);

        printf("The calculation result is as follows \n");

        fprintf(stdout, "%d\n", i * 10);

 

        return 0;

}