c program to subtract between two numbers without using '-'
sign and subtract function.
Answers were Sorted based on User's Feedback
Answer / davic uwihoreye
Write a c program or code to subtract two numbers without
using subtraction operator
#include<stdio.h>
int main(){
int a,b;
int sum;
printf("Enter any two integers: ");
scanf("%d%d",&a,&b);
sum = a + ~b + 1;
printf("Difference of two integers: %d",sum);
return 0;
}
Sample Output:
Enter any two integers: 5 4
Difference of two integers: 1
| Is This Answer Correct ? | 9 Yes | 1 No |
Which command is more efficient? *(ptr+1) or ptr[1]
What is the need of structure in c?
What are the 4 types of unions?
What is function what are the types of function?
What is d scanf?
how to swap two integers 1 and 32767 without using third variable
how to print this sereis 2 4 3 6 5..........?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
What are the difference between a free-standing and a hosted environment?
What are the types of variables in c?
what's the o/p int main(int n, char *argv[]) { char *s= *++argv; puts(s); exit(0); }
what is the difference between getch() and getchar()?