Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

Can we execute printf statement without using semicolan?
Yes,We can execute printf statement without using semicolan. When we write printf inside the if,for,while,do while etc it gives output.
Example:
void main()
{
   if(printf("R4R Welcomes you!"))
   {
      /*statements*/
   }
getch();
}

void main()
{
   while(printf("Welcome"))
   {
      /*statements*/
   }
getch();
} 

int main()
{
   int flag = 1;
   int test = 10;
   if (printf("%d",test))
   flag = 0;
   else
   flag = 1;
   return 0;
}
o/p will be 10 and after that when we check the value of flag, it shows 0.return type of printf is int.