/*C++ version of Program To Multiply Two Integers Without Using Product/Multiply Operator*/
#include<iostream>
using namespace std;
int main()
{
int a,b,sum=0;
cout<<"Enter The Value Of A: ";
cin>>a;
cout<<"Enter The Vlaue Of B:";
cin>>b;
while(b!=0)
{
sum = sum +a;
b--;
}
cout<<"Product="<<sum<<endl;
system("pause");
return 0;
}
----------------------------------------------------------------------------------------------------------
/*C version of Program To Multiply Two Integers Without Using Product/Multiply Operator */
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,sum=0;
printf("Enter The Value Of A: ");
scanf("%d",&a);
printf("Enter The Vlaue Of B:");
scanf("%d",&b);
while(b!=0)
{
sum = sum +a;
b--;
}
printf("Multiply %d",sum);
getch();
return 0;
}
Output:
#include<iostream>
using namespace std;
int main()
{
int a,b,sum=0;
cout<<"Enter The Value Of A: ";
cin>>a;
cout<<"Enter The Vlaue Of B:";
cin>>b;
while(b!=0)
{
sum = sum +a;
b--;
}
cout<<"Product="<<sum<<endl;
system("pause");
return 0;
}
----------------------------------------------------------------------------------------------------------
/*C version of Program To Multiply Two Integers Without Using Product/Multiply Operator */
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,sum=0;
printf("Enter The Value Of A: ");
scanf("%d",&a);
printf("Enter The Vlaue Of B:");
scanf("%d",&b);
while(b!=0)
{
sum = sum +a;
b--;
}
printf("Multiply %d",sum);
getch();
return 0;
}
Output:
Write a C / C++ Program To Multiply Two Integers Without Using Product/Multiply Operator |
0 comments:
Post a Comment