#include <stdio.h>

#include <stdlib.h>

int main()
{
int num[100]={0};
int i,n=0;
for(i=0; num[i] != EOF ; i++,n++)
{
scanf("%d",&num[i]);
}
printf("%d\n", i);
while(i=0;i<n;i++)
printf("%d ",num[i]);
printf("\n");
system("pause");
return 0;
}

That's my code that I wrote and the input shoul be 123 ctrl z and the out output should be 3 but the code that I wrote if I wrote an input it gives me 107 output....Can anyone help me to figure out the problem....

2 answers

Sorry this is the one that I wrote with an error the first one is incorrect....

#include <stdio.h>
#include <stdlib.h>

int main()
{
int num[100]={0};
int i,n=0;
for(i=0; num[i] != EOF ; i++,n++)
{
scanf("%d",&num[i]);
}
printf("%d\n", i);
For(i=0;i<n;i++)
printf("%d ",num[i]);
printf("\n");
system("pause");
return 0;
}
Assistance needed.
Similar Questions
  1. #include <iostream.h>#include <stdlib.h> #include <math.h> int main ( ) { double noe, nod, dc1, dc2, dc3, dc4, t; cout << "Enter
    1. answers icon 1 answer
  2. #include <iostream.h>#include <stdlib.h> #include <math.h> int main ( ) { double noe, nod, dc1, dc2, dc3, dc4, t; cout << "Enter
    1. answers icon 9 answers
  3. how can a modfiy this source code to a menu.#include <stdio.h> #include <stdlib.h> #include <time.h> main() { char cYesNo =
    1. answers icon 0 answers
  4. Would you check and correct my error please!******************************* #include<iostream.h> #include<string.h>
    1. answers icon 0 answers
more similar questions