Translate

Labels

Tuesday 13 August 2013

C PUZZLES

Basic Arithmetic Operators

mian()
{
int x;
x=- 3 + 4 * 5 -6;    /*1*/
printf("%d\n",x);
x=3 + 4 % 5 - 6;     /*2*/
printf("%d\n",x);
x=- 3 *4 %-6 / 5;    /*3*/
printf("%d\n",x);
x=(7+6)%5/2;         /*4*/
printf("%d\n",x);
}


1.x=- 3 + 4 * 5 -6;             by reading the precedence table

   x=(- 3) + 4 * 5 -6;          The highest level operator in the expression is the unary -. We'll use                                                                parentheses indicate the order of binding operands to operators. 
   x=(- 3) + (4 * 5) -6;        Next highest in the expression is *.

  

Friday 2 August 2013

PROGRAM TO FIND GCD OF TWO INTEGERS

GCD
mian()
{
int a,b ;
printf("Enter two positive integers :\n");
scanf("%d%d",&a,&b);
printf("GCD of %d and %d is %d\n",a,b,gcd(a,b));
}
gcd(int a,int b)
{
if(a)
return(b?gcd(b,a%b):a);
else
return b;
}



OUTPUT
Enter two positive integers
24   36
GCD of 24 and 36 is 12