달력

52025  이전 다음

  • 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
  • 31

// 예제 5 - 3 - 1
/*
 * 단순 if 예제
*/
/*
#include <stdio.h>
#define MIN 60

void main()
{
 int score;

 printf("현재 점수를 입력하시오. : ");
 scanf("%d",&score);

 if( score < 60 )
 {
  printf("\n 기본 최저점을 받게 됩니다. \n");
  score = MIN;
 }

 printf("당신은 %d 점 입니다.\n", score);
}

 

// 예제 5 - 3 - 2
/*
 * 단순 if 예제
*/
/*
#include <stdio.h>
#define MIN 60

void main()
{
 int score;

 printf("현재 점수를 입력하시오. : ");
 scanf("%d",&score);

 if( score < 60 )
 {
  printf("\n 기본 최저점을 받게 됩니다. \n");
  score = MIN;
 }
 else  // 이렇게 하면 내용 자체가 이상해짐
  printf("당신은 %d 점 입니다.\n", score);
}
*/

// 예제 5 - 3 - 3
/*
 * 단순 if 예제
*/
/*
#include <stdio.h>
#define MIN 60

void main()
{
 int score;

 printf("현재 점수를 입력하시오. : ");
 scanf("%d",&score);

 if( score < 60 )  // 중괄호를 없앰
  printf("\n 기본 최저점을 받게 됩니다. \n");
  score = MIN;
 
 printf("당신은 %d 점 입니다.\n", score);
}
*/


// 예제 5 - 3 - 4
/*
 * 단순 if 예제
*/
/*
#include <stdio.h>
#define MIN 60

void main()
{
 int score;

 printf("현재 점수를 입력하시오. : ");
 scanf("%d",&score);

 if( score < 60 )
 { 
  printf("\n 기본 최저점을 받게 됩니다. \n");
  score = MIN;
 }
 else
  ;
  printf("당신은 %d 점 입니다.\n", score);
}
*/

// 미완성
// 100개의
#include <stdio.h>

void main()
{
 int j, a, sum = 0; float avg;

 j = 0;
 while( j < 100 )
 {
  printf("숫자입력");
  scanf("%d",&a);
  sum = sum + a;
  j++;
 }
 avg = sum / 100;
 printf("%d", avg);
}

'매니저 > C' 카테고리의 다른 글

20120510 학교 수업  (0) 2012.05.10
20120504 학교 수업  (0) 2012.05.04
20120420 학교 수업  (0) 2012.04.20
20120419 학교  (0) 2012.04.19
학교 5강 예제  (0) 2012.04.18
Posted by cdprkr2077
|