Multiplication Table using Python program

January 04, 2020


              Hello, In this blog we see the Python code to print multiplication table. In this program user give the input and depends on that integer number the multiplication table will displayed.

Code:
num = int(input("Display multiplication table of? "))
for i in range(1, 11):
   print(num, 'x', i, '=', num*i)

In the above code we use the range function. So easily we compact the code as compare to c, c++, java. In last print line all the operations are taken in one line and the output is displayed to the user.
Output:

Display multiplication table of? 12
12 x 1 = 12
12 x 2 = 24
12 x 3 = 36
12 x 4 = 48
12 x 5 = 60
12 x 6 = 72
12 x 7 = 84
12 x 8 = 96
12 x 9 = 108
12 x 10 = 120


Multiplication Table using Python program Multiplication Table using Python program Reviewed by Amit Waghmare on January 04, 2020 Rating: 5

Multiplication Table using C++ program

January 04, 2020


C++ program to print Multiplication Table

                    Hello, In this blog we see the c++ program code to print multiplication table. In this program user give the input and depends on that integer number the multiplication table will displayed.

Code:
#include<iostream.h>
#include<conio.h>
void main()
{
 int s;
 clrscr();
    cout<<"Enter the number to print the multiplication table: ";
    cin>>s;
    cout<<"\n";
 for(int i=1; i <= 10; i++)
 {
     cout<<s;
     cout<<" * ";
     cout<<i;
     cout<<" = ";
     cout<<s*i;
     cout<<"\n";
 }
getch();
}


         In the above code we use variable 's' to store the input value. And by using for loop the actual multiplication table is displayed.

Output:

Enter the number to print the multiplication table: 9
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90

Multiplication Table using C++ program Multiplication Table using C++ program Reviewed by Amit Waghmare on January 04, 2020 Rating: 5

Multiplication Table using C program

January 04, 2020


C program to print Multiplication Table

                    Hello, In this blog we see the c program code to print multiplication table. In this program user give the input and depends on that integer number the multiplication table will displayed.

Code:
#include<stdio.h>
#include<conio.h>
void main()
{
 int s,i,a;
 clrscr();
    printf("Enter the number to print the multiplication table: ");
    scanf("%d",&s);
    printf("\n");
 for(i=1; i <= 10; i++)
 {
     printf("%d",s);
     printf(" * ");
     printf("%d",i);
     a=s*i;
     printf("=%d",a);
     printf("\n");
 }
getch();
}


         In the above code we use variable 's' to store the input value. And by using for loop the actual multiplication table is displayed.

Output:

Enter the number to print the multiplication table:7
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
7 * 10 = 70


Multiplication Table using C program Multiplication Table using C  program Reviewed by Amit Waghmare on January 04, 2020 Rating: 5

Multiplication Table using Java program

January 04, 2020


Java Code to print Multiplication Table

                    Hello, In this blog we see the java code to print multiplication table. In this program user give the input and depends on that integer number the multiplication table will displayed.

Program:
import java.util.Scanner;
public class MultiTable1
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
 System.out.print("Enter number:");       
 int n=s.nextInt();
        for(int i=1; i <= 10; i++)
        {
            System.out.println(n+" * "+i+" = "+n*i);
        }
    }
}

                  In the above code we use variable 's' to store the input value. And by using for loop the actual multiplication table is displayed.

Output:






Multiplication Table using Java program Multiplication Table using Java program Reviewed by Amit Waghmare on January 04, 2020 Rating: 5

Fibonacci series using Java program

January 02, 2020


                     Hello friends, In this blog we see the how to generate Fibonacci series using java. In C, CPP and Python programs we see what is Fibonacci series. So Without giving the definition of Fibonacci series we see the program.

Program:
1. (Using for loop)
public class Fibonacci
{
    public static void main(String[] args)
{
        int a = 0, b = 1;
        System.out.println("First 10 terms: ");
        for (int i = 1; i <= 10; ++i)
        {
            System.out.println(a + "  ");
            int sum = a + b;
            a = b;
            b = sum;
        }
    }
}


           In  the above program we use two variables that is a and b and assign the value 0 and 1 respectively. For loop is used to initialize the value of 'i' variable and increment it by 1. And we put the condition that is the 'i' must be less than or equal to 10. So we see the output of 10 numbers only.


2. Using while loop

public class Fibonacci
{
    public static void main(String[] args)
{
        int i = 1, a = 0, b = 1;
        System.out.println("First 10 terms: ");
        while(i<=10)
        {
            System.out.println(a + "  ");
            int sum = a + b;
            a = b;
            b = sum;
            i++;
        }
    }
}

In the above code instead of for loop we use the while loop and incremented I variable in the middle loop. The output of both code is exactly same.
   
Output:





Fibonacci series using Java program Fibonacci series using Java program Reviewed by Amit Waghmare on January 02, 2020 Rating: 5

Cpp language code to print fibonacci series

January 02, 2020

CPP LANGUAGE CODE TO PRINT FIBONACCI SERIES


Introduction
                 

                              Fibonacci series means if we are giving input as 7 then the output is 0  1  1  2  3  5.
Means in output first digit is 0 then second is 1, addition of first and second digit is third digit i.e.0+1=1, next is 1+1=2, then 2+1=3, then 3+2=5.
                    The next digit is 5+3=8 but 8 is greater than 7(8>7) i.e.(8!<7) so the control is transfer to the
out of the loop.The actual code is as follows:

code:

#include<iostream.h>
#include<conio.h>
void main()
{
int no,a=0,b=1,c=0;
clrscr();
cout<<"Enter the number to print fibonacci series:";
cin>>no;
while(no>c)
{
cout<<c;
c=a+b;
b=a;
a=c;
}
getch();
return 0;
}
------------------------------------------------------------------------------------------------------------
Output:
           Enter the number to print fibonacci series:7
           0  1  1  2  3  5
     



Cpp language code to print fibonacci series Cpp language code to print fibonacci series Reviewed by Amit Waghmare on January 02, 2020 Rating: 5