/*Write a function named myMessage() that prints the following message until the user inputs a non-negative integer.
But it will not print the message more than N times which is taken from caller. The function should return the number
of times that it prints the message to the caller.
"This is an imaginary world and I am alive in this world"*/
#include
int myMessage(int Lim);
int main()
{
int N,result;
scanf("%d",&N);
result=myMessage(N);//U can deny this declaration line(#prototype) by defining the function before main()
printf("%d",result);
return 0;
}
int myMessage(int Lim)
{
int i,a,cnt=0;
if(Lim==0)return cnt;//If we consider the case N can be equal to 0
scanf("%d",&a);
while(a<0)
{
printf("This is an imaginary world and I am alive in this world\n");
cnt++;
if(cnt==Lim)//You can put ">=" in stead of "=="
break;
scanf("%d",&a);
}
return cnt;
}