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 scanf. Show all posts
Showing posts with label scanf. Show all posts
Oct 12, 2012
Oct 9, 2012
Introducing scanf
scanf is an instruction that saves a number or value in a variable, is used after a printf. This time I'll use it for sum two numbers, the program will ask for that numbers and then show the result.
#include <stdio.h>
main()
{
int st_num;
int nd_num;
int rslt;
printf("Enter the first number right here ---> ");
scanf ("%d", &st_num);
printf("Enter the second number right here --> ");
scanf ("%d", &nd_num);
rslt = st_num + nd_num;
printf("Your result is %d", rslt);
getchar();
getchar();
}
#include <stdio.h>
main()
{
int st_num;
int nd_num;
int rslt;
printf("Enter the first number right here ---> ");
scanf ("%d", &st_num);
printf("Enter the second number right here --> ");
scanf ("%d", &nd_num);
rslt = st_num + nd_num;
printf("Your result is %d", rslt);
getchar();
getchar();
}
Subscribe to:
Posts (Atom)