2016-10-18 2 views
-6

어떤 이유로 인쇄본과 scanf가 명백하게 표시되지 않습니다. 나는 그것이 내가 잘 이해하지 못하는 내 기능들과 관련이 있다고 생각한다.간단한 계산 프로그램 문제

#include<stdlib.h> 
#include<stdlib.h> 
#include<ctype.h> 

void testCount(); 

int eleven = 11; 
int input = 0; 
int output = 0; 
int count = 0; 

int main(){ 
    printf("What number would you like to count to?"); 
    scanf("%d", &count); 
    testCount(); 
    system("pause"); 
    return 0; 
} 

void testCount (int x){ 
    int y; 
    for(y=1;y<count;y++){ 
     if (x < 10){ 
      x + 1; 
     } 
    }  
    output = input/eleven; 
} 
+1

이 무효 testCount (INT)'에 변화가 testCount'는 다른'의 프로토 타입과 기능 서명,'또한, 잊지는에'count'을 통과 'testCount(); ' –

+2

가장 이상한 프로그램 !!! – AhmadWabbi

답변

2

당신은 printf()scanf()으로 문제를 해결하기 위해 #include <stdio.h>해야합니다. #include <stdlib.h> 두 번 있습니다.

또한, 당신은 변경해야합니다 :

void testCount(); 

에 :

void testCount (int x); 

@ Keine 정욕에 의해 제안. 새로 작성된 testCount() 기능에 가치를 전달하는 것을 잊지 마십시오!

+0

* facepalming * ... – Treycos

+0

오케이, 미안하지만 어리석은 실수였습니다. 도움을 주셔서 감사합니다 :) – SubZeroFish

+0

때로는 가장 단순한 것들을보기 위해 다른 눈알 세트가 필요합니다 :) –

0

프로그램에 오류가 많이 있습니다.

  1. <stdlib.h>을 두 번 신고하셨습니다.
  2. 인쇄물을 출력하지 않습니다.
  3. testcount()는 Output을 출력하거나 main()으로 반환해야합니다.
  4. testcount()는 argumnet으로 간주됩니다.

    다음과 같이 변경합니다 :

    #include <stdlib.h> 
    #include <stdio.h>  //declaration of stdio lib 
    #include <ctype.h> 
    
    void testCount (int); // declaration of datatype of parameter 
    
    int eleven = 11; 
    int input = 0; 
    int output = 0; 
    int count = 0; 
    
    int main() 
        { 
    printf("What number would you like to count to?"); 
    scanf("%d", &count); 
    testCount(count);   // pass value of count so function testcount() can copy that value to variable x 
    system("pause");  // no need of this line 
    return 0; 
    } 
    
        void testCount (int x) 
        { 
        int y; 
        for(y=1;y<count;y++) 
        { 
    
    
    if (x < 10) 
        { 
        x + 1; 
        } 
        }  
        output = input/eleven; 
    
        printf("Output is :%d",output); 
        } 
    
+0

고맙습니다. 지금 고칠 생각입니다. – SubZeroFish