Home
User Guide
DB Recovery
Download
Documents
FAQ
Books
About Me
C Programs
Stats

/* 
   Program# 18
   date : 25-12-2008
   Single digit or not 
*/

#include <stdio.h>
main(){
int n;
printf("\nEnter a positive number :");
scanf("%d",&n);
if(n>=0 && n<=9)  
printf("Single digit number");// this will be printed, only if both the conditions are true.
else
printf("Not a Single digit number");
}
output:
Enter a positive number : 5
Single digit number


Things to note: Hierarchy of operators:

OperatorsType
!Logical NOT
* / % Arithmetic and modulus
+ - Arithmetic
< > <= >= Relational
== != Relational
&& Logical AND
|| Logical OR
= Assignment

Since the relational operator has higher precedence over Logical AND, it is evaluated first and the result is combined with && to give the result.

Powered by
Open Source Programmers