/* */ Click to Join Live Class with Shankar sir Call 9798158723

multiplication of two numbers in C ?


Q.) multiplication of two no. in C by getting input from user ?
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	 int a,b,product;          //declaring variable
	 printf("Enter two numbers :");    
	 scanf("%d%d",&a,&b);             
     product = a * b;                
     printf("product of two numbers :%d",product);
     getch();               
 }
Output
Enter two numbers :5 8    /* say a = 5 & b = 8 */.
product of two numbers :40

Program Explanation


Step 1: Include header files (#include<stdio.h> and #include<conio.h>).

Step 2: Start with main function with return type.

Step 3: parenthesis to start and end the program { }.

Step 4: declare the variables with data types. i.e, values of 'a' and 'b' are of integer type, so we declare 'a' and 'b' variable with "int" data type. We also declare 'product' as int variable because it returns an integer value.

Step 5: Use output function printf() to print the output on the screen.

Step 6: use input function scanf() to get input from the user.

Step 7: using getch() function to hold the screen.