Long is a type of data that allows a plenty of numbers, if you need to show too much numbers, here's your type. By the way, signed and unsigned not work for long. Unsigned int is the same memory space for long, so use it as you want.
#include <stdio.h>
main()
{
long st, nd;
printf("Enter the first number ");
scanf("%d", &st);
printf("Enter the second number ");
scanf("%d", &nd);
printf("The result is %d", st * nd);
getchar();
getchar();
getchar();
}
Showing posts with label multiplication. Show all posts
Showing posts with label multiplication. Show all posts
Oct 12, 2012
Using formulas and multiplicating with variables
The program will ask you for the numbers and show the result, for my opinion, I'll put a clrscr(); under the first getchar();. I have to learn the pow instruction, I knew how to do this without the math.h header but I lost that code. Nevermind, enjoy the program.
#include <stdio.h>
main()
{
int a, b, st_rslt, nd_rslt;
printf("Enter the first number ");
scanf("%d", &a);
printf("Enter the second number ");
getchar();
scanf("%d", &b);
st_rslt = (a+b)*(a-b);
nd_rslt = (a * a) - (b * b);
printf("The result of the (a+b)*(a-b) formula is %d", st_rslt);
getchar();
getchar();
printf("The result of the a^2-b^2 formula is %d", nd_rslt);
getchar();
}
#include <stdio.h>
main()
{
int a, b, st_rslt, nd_rslt;
printf("Enter the first number ");
scanf("%d", &a);
printf("Enter the second number ");
getchar();
scanf("%d", &b);
st_rslt = (a+b)*(a-b);
nd_rslt = (a * a) - (b * b);
printf("The result of the (a+b)*(a-b) formula is %d", st_rslt);
getchar();
getchar();
printf("The result of the a^2-b^2 formula is %d", nd_rslt);
getchar();
}
Subscribe to:
Posts (Atom)