difference of two no's with out using - operator

Answer Posted / santhi perumal

#include<stdio.h>
#include<conio.h>

//To calculate a-b
void main()
{
int a,b,min,max;

printf("Enter the value of a and b \n");
scanf("%d %d",&a,&b);
min = (a<b)?a:b;
max = (a>b)?a:b;
while(min--) max--;

if(a<b)
printf("-%d",max);
else
printf("%d",max);
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is dynamic data structure?

636


Write a program to find factorial of a number using recursive function.

632


How to throw some light on the b tree?

598


An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array

678


What are the Advantages of using macro

673






What is zero based addressing?

699


What is the data segment that is followed by c?

600


What are the advantages of union?

619


You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.

1770


Write a program on swapping (100, 50)

631


What is c value paradox explain?

563


write a c program in such a way that if we enter the today date the output should be next day's date.

1675


Can include files be nested? How many levels deep can include files be nested?

649


Do you know null pointer?

596


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

2379