Thursday 14 March 2013

Calculate the multiple of two given numbers.


Statement:
Calculate the multiple of two given numbers.





      Algorithm:

                                                Step 1: Read a 
                                                Step 2: Read b
                                                Step 3: c=a*b
                                                Step 4: print c
                                                Step 5: End





v Program Listing:

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Please enter a number:");
scanf("%d",&a);
printf("\nPlease enter another number:");
scanf("%d",&b);
c=a*b;
printf("\nThe multiple of two numbers is:%d",c);
getch();
}



·  Output:
Please enter a number: 42
Please enter another number: 56
The multiple of two number is: 2352





§  Discussion:
                                                I.            It works properly.
                                              II.            We can made the multiple of more than two numbers similarly.
                                            III.            Since we use short signed int so it works within the number range  -32768  to +32767
                                           IV.            If we use long int then it works within the number range   -2147483648  to  +2147483647

No comments:

Post a Comment