Wednesday, 13 February 2013

Java program to multiply three integer numbers without using * operator.

Basic idea of this java program to show varies methods of problem solving techniques, although we have standard operator " * "  to perform the basic operation of multiplication. Our aim is to do that without using " * "   operator we will show you multiplication operation on integer but you can extend it to your aspect of need.


 package arraymultithree1;  
 public class ArrayMultiThree1  
 {  
   public static void main(String[] args)   
   {  
      int a=2,b=3,c=4;  
      System.out.printf("the nos are %d %d %d \n" ,a,b,c);  
      System.out.printf("mutiplication of three nos are given below \n" );  
    int s=0;  
 if (a==0 || b==0 || c==0)  
 {  
 System.out.printf("sorry !! \n should be non zero entry \n");    
 }  
 else  
 {  
 for (int i=0;i<b;i++)  
 {    
 s=s+a;  
 }     
 int sum=0;  
 for (int j=0;j<c;j++)  
 {  
 sum=sum+s;  
 }  
  System.out.printf("%d\n",sum );  
 }      
   }  
 }  


No comments:
Write comments

Featured post

List of Universities in Karnataka offering M.Sc Computer Science

The post-graduate programme in Computer Science (M.Sc Computer Science) contains two academic years duration and having a four semesters....

Popular Posts

Copyright @ 2011-2016