difference of two no's with out using - operator
Answers were Sorted based on User's Feedback
Answer / arpit
void count()
{
int c=0;
for(i=a;i<=b;i++)
{
c++;
}
return(c);
}
c=b-a :...easy and best .....
| Is This Answer Correct ? | 10 Yes | 5 No |
Answer / gg
Try this....
main()
{
int a,b;
printf("Enter two integers \n");
scanf("%d%d",&a,&b);
printf("The diff is : %d ",a+(~b+1));
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / supri
see subtraction itself is the addition of the number with
its 2's complement....
add(int a,int b)
{
if(!a)
return b;
else
return(add((a&b)<<1,a^b));
}
main()
{
int a,b;
scanf("%d%d",&a,&b);
b=add(~b,1);
printf("%d",add(a,b));
return;
}
u can try this...
| Is This Answer Correct ? | 2 Yes | 1 No |
#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 |
Answer / sandeep
int count(int a , int b)
{
int c=0;
if(a<b)
for(i=a;i<=b;i++)
{
c++;
}
else
for(i=b;i<=a;i++)
{
c++;
}
return(c); }
www.NSITFORUM.co.cc
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / dally
#include<stdio.h>
int main()
{
int a=9,b=4;
if(a>b)
{
while(a--)
b = b--;
}
else
printf("Difference is not possible\n") ;
}
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / vignesh1988i
its simple logic , wat i think is to AND these two inputs.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,m;
scanf("%d %d",&m,&n);
if(m>n)
printf("%d",m&n);
else
printf("%d",n&m);
getch();
}
thank u
| Is This Answer Correct ? | 1 Yes | 10 No |
What is the Lvalue and Rvalue?
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none
explain what are pointers?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
Find MAXIMUM of three distinct integers using a single C statement
#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } what will happen if you executed this code?
What does #pragma once mean?
What is a structure member in c?
HOW TO SWAP TWO NOS IN ONE STEP?
what is purpose of fflush(stdin) function
Why is c so important?
What are the benefits of organizational structure?