Way 1 : Using Recursive Function
#include<stdio.h> #include<conio.h> int add(int,int); void main() { int a,b; clrscr(); printf("Enter the two Numbers: "); scanf("%d%d",&a,&b); printf("Addition of two num. is : %d",add(a,b)); getch(); } //----------------------------------------------- int add(int a, int b) { if (!a) return b; else return add((a & b) << 1, a ^ b); }
Way 2 : Using While Loop
#include<stdio.h> #include<conio.h> void main() { int a=10,b=5,i; clrscr(); while(b>0) { a++; b--; } printf("%d",a); getch(); }
Way 3 : Using While Loop
#include<stdio.h> #include<conio.h> void main() { int a=10,b=5; while(b--) a++; printf("Sum is : %d" a); }
Way 4 : Using For Loop
#include<stdio.h> #include<conio.h> int sum(int,int); void main() { int a,b; clrscr(); printf("Enter the two Numbers: "); scanf("%d%d",&a,&b); printf("Addition of two num. is : %d",add(a,b)); getch(); } int add(int num1,int num2) { int i; for(i=0;i< num2;i++) num1++; return num1; }
Way 5 : Using Subtraction
Note : This Example have Arithmetic Operator [-] but this example is for "Adding two numbers without using + Operator "#include<stdio.h> #include<conio.h> void main() { int a=10,b=5; a = a-(-b); printf("Sum is : %d" a); }

0 comments
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email