first of all, it's my First time in this site. when i submitted this code it says "runtime error (SIGSEGV) "
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int num[1000] ,y=0 , i , x , z , flag=0;
printf("Input:\n");
for(i=0;i<10;i=i+clock()/CLOCKS_PER_SEC)
{
scanf("%d",&x);
if ( x == 42 )
{
z=y;
flag=1;
}
else
{
num[y]=x;
y=y+1;
}
}
printf("Output:\n");
if ( flag == 1 )
{
for(i=0;i<z;i++)
{
printf("%d\n",num[i]);
}
}
else
for(i=0;i<y;i++)
{
printf("%d\n",num[i]);
}
return 0;
}
created
last reply
- 6
replies
- 1.5k
views
- 2
users
- 3
links