c program to subtract between two numbers without using '-'
sign and subtract function.

Answers were Sorted based on User's Feedback



c program to subtract between two numbers without using '-' sign and subtract function...

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

c program to subtract between two numbers without using '-' sign and subtract function...

Answer / 080132

Do anybody give correct ans

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More C Interview Questions

What is bubble sort technique in c?

0 Answers  


How do you access command-line arguments?

1 Answers  


What is null pointer constant?

0 Answers  


What will the preprocessor do for a program?

0 Answers   Aspire, Infogain,


b) 4 c) 6 d) 7 32. Any C program a) must contain at least one function b) need not contain ant function c) needs input data d) none of the above 33. Using goto inside for loop is equivalent to using a) continue b) break c) return d)none of the above 34. The program fragment int a=5, b=2; printf(“%d”,a+++++b); a) prints 7 b)prints 8 c) prints 9 d)none of the above 35. printf(“ab” , “cd”,”ef”); prints a) ab abcdef c) abcdef, followed by garbage value d) none of the above 36. Consider the following program segment. i=6720; j=4; while((i%j)==0) { i=i/j; j=j+1; } On termination j will have the value a) 4 b) 8 c) 9 d) 6720

1 Answers   HCL,






if array a conatins 'n' elements and array b conatins 'n-1' elements.array b has all element which are present in array a but one element is missing in array b. find that element.

18 Answers   Parexel, Ram Infotech, Zycus Infotech,


can we declare a function in side the structure?

2 Answers   HCL,


int main() { int days; printf("enter days you are late"); scanf("%d",days); if (days<=5) printf("5o paisa fine"); if (days<=10&&days>=6) printf("1rs fine"); if(days>10) printf("10 rs fine"); if(days=30) printf("membership cancelled"); return 0; } tell me whats wrong in this program? is it right?

2 Answers  


wt is diference between int and int pointer as same as float and float pointer and char and char pointer

8 Answers   CTS, Infosys,


What is meant by gets in c?

0 Answers  


How to reverse a linked list

1 Answers   Aricent, Fidelity, IBM, TCS,


What is the -> in c?

0 Answers  


Categories