GeekInterview.com
Series: Subject: Topic:
Question: 17 of 587

Accept two numbers from the user...

...and multiply these two numbers without using the multiplication operator! using any loop!
Asked by: cguyc | Member Since Jul-2012 | Asked on: Jul 20th, 2012

View all questions by cguyc

Showing Answers 1 - 2 of 2 Answers
Er.Kunal

Answered On : Jul 22nd, 2012

View all answers by Er.Kunal

I have included the code herein for u.

Code
  1.  
  2.  
  3. //Program for Multiplication without using multiplication operator written by Er.Kunal
  4. #include<stdio.h>
  5. #include<conio.h>
  6. void main()
  7. {
  8.    int multiplicand,multiplier,i,result=0;
  9. clrscr();
  10. printf("Enter multiplicand and multiplier:");
  11. scanf("%d%d",&multiplicand,&multiplier);
  12. You entered multiplicand=%d
  13. multiplier=%d",multiplicand,multiplier);
  14. for(i=1;i<=multiplier;i++)
  15. {
  16. result=result+multiplicand;
  17. }
  18. Your Result is:%d",result);
  19. getch();
  20. }

  
Login to rate this answer.
Delbin

Answered On : Jul 22nd, 2012

Code
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. main()
  4. {
  5.         int a,b,result=0;
  6.         scanf("%d%d",&a,&b);
  7.         while(a)
  8.         {
  9.                 result=result+b;
  10.                 a--;
  11.         }
  12.         printf("%d
  13. ",result);
  14. }

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.