NO

Author Topic: ! NOT operator  (Read 3017 times)

puredesi5

  • Guest
! NOT operator
« on: April 10, 2013, 04:46:51 AM »
According to C books,   ! operator should work but it doesn't. Without ! code    works fine. Am I missing something?
I get following error.
Quote
Building main.obj.
C:\Users\Ba\Documents\Pelles C Projects\T11\main.c(9): error #2001: Syntax error: expected '(' but found '!'.
C:\Users\Ba\Documents\Pelles C Projects\T11\main.c(10): error #2001: Syntax error: expected ')' but found '{'.
*** Error code: 1 ***
Done.
Code: [Select]
#include<stdio.h>

int main()
{
int mynumber;
printf (" Please enter a number \n");
scanf("%d",&mynumber);

if !(mynumber == 10 )
{
printf("Is equal  \n" );
printf("Closing program\n");
}
else
{
printf("Not equal\n");
printf("Closing program\n");
}
       
return 0;
}
« Last Edit: April 11, 2013, 11:34:18 PM by Stefan Pendl »

CLR

  • Guest
Re: ! NOT operator
« Reply #1 on: April 10, 2013, 05:14:19 AM »
if (!(mynumber == 10))

puredesi5

  • Guest
Re: ! NOT operator
« Reply #2 on: April 10, 2013, 07:17:05 AM »
Thnks! That worked. I really appreciate it.