기록해! 정리해!

Rinux(예제 1) 본문

Rinux

Rinux(예제 1)

zsuling 2022. 6. 3. 16:00

6/03

 

예제1) 1에서 5까지 출력해보시오

 

#include <stdio.h>
#include <stdlib.h>
void main(){
  for(int i =1; i<=5; i++){
  printf(" %d ", i);
  printf("\n");
  }
}

 

또는 

#include 
#include 
void main(){
  for(int i=1; i<=5; i++){
  printf(" %d/n", i);

 }

}

결과값:

1

2

3

4

5

 

#include 
#include 
void main(){
  for(int i=1;i<=5;i++){
  printf("%d ", i);

}

}

결과값:

1 2 3 4 5

 

예제2) 5까지 출력하고 누적합도 출력하시오

 

#include <stdio.h>
#include <stdlib.h>
void main(){
   int s = 0;
   for(int i=1; i<=5; i++){
   printf("%d", i);
   s += i;
   printf("\n");
  }
  printf("\n ===== /n");
  printf("누적합: %d", s);

}

 

예제3) 7단만 세로로 출력하시오

 

#include <stdio.h>
#include <stdlib.h>
void main(){

 int dan = 7;
  for(int i=1; i<=9; i++){
   printf("7X%d=%d\n", i, 7*i);
  }
 }                                                                      

 

 

 

 

 

 

 

'Rinux' 카테고리의 다른 글

Rinux (5) -아파치 데몬 핸들링  (0) 2022.06.07
Rinux (4)  (0) 2022.06.03
Rinux(3) -C언어 실습  (0) 2022.06.03
Rinux(2)  (0) 2022.06.03
Rinux (1)  (0) 2022.05.31
Comments