Precedence and Order of Evaluation examples
1.
/* hirarchy operations */
int k;
int k;
k=3/2*4+3/8+3
--> 1*4+3/8+3
--> 4+3/8+3
--> 4+0+3
--> 7
--> 1*4+3/8+3
--> 4+3/8+3
--> 4+0+3
--> 7
2.
/* hirarchy operations */
g=big/2+big*4/big-big+abc/3;
(abc=1.5 , big=3 ,assume g is float)
g = 3/2+3*4/3-3+1.5/3
= 1+12/3-3+1.5/3
g=big/2+big*4/big-big+abc/3;
(abc=1.5 , big=3 ,assume g is float)
g = 3/2+3*4/3-3+1.5/3
= 1+12/3-3+1.5/3
More..
Precedence and Order of Evaluation
The rules for precedence and associativity of all operators. Operators on the same line have the same precedence; rows are in order of decreasing precedence, so, for example, *, /, and % all have the same
More..
Program to tell the given number is Even or Odd
#include < stdio.h >
main()
{
int number;
{
int number;
printf("Enter number\n");
scanf("%d", &number);
scanf("%d", &number);
if(number % 2 == 0)
More..
Program to do sum of two values using functions
#include < stdio.h >
int sumfun(int numa, int numb);
main()
{
int a = 10, b = 20;
int sum;
{
int a = 10, b = 20;
int sum;
sum = sumfun(a, b);
No comments:
Post a Comment