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 |
1. Write the function int countchtr(char string[ ], int ch); which returns the number of times the character ch appears in the string. Example, the call countchtr(“She lives in NEWYORK”, ‘e’) would return 3.
What is selection sort in c?
WHAT IS RTGS N MINIMUM AMT TO B TRANSFERD N WHAT R THE CHARGES ON MINIMUM AMT N IN WHICH BANK WE CAN DO IT?
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
What is the difference between typeof(foo) and myFoo.GetType()?
What is function definition in c?
Write a program to check whether a number is prime or not using c?
What does char * * argv mean in c?
a value that does not change during program execution a) variabe b) argument c) parameter d) none
Write a program which has the following seven functions. The functions should be: • main() this calls the other 6 functions • fget_long() a function which returns a long data type from a file • fget_short() a function which returns a short integer variable from a file • fget_float() a function which returns a floating point variable from a file • fprt_long() a function which prints its single, long argument into a file • fprt_short() a function which prints its single, short argument into a file • fprt_float() a function which prints its single, floating point argument into a file. You should use fscanf() to get the values of the variables from the input (the file) and fprintf() to print the values to the other file. Pay attention to using the correct format for each of the data types.
Tell me what is null pointer in c?
What is ## preprocessor operator in c?