C/Console/Console Output Int
Содержание
Do calculation inside printf
#include <stdio.h>
int main(void)
{
int len, width, height;
printf("Enter length: ");
scanf("%d", &len);
printf("Enter width: ");
scanf("%d", &width);
printf("Enter height: ");
scanf("%d", &height);
printf("Volume is %d.", len * width * height);
return 0;
}
Output int value
#include <stdio.h>
int main(void)
{
int num;
num = 100;
printf("num = %d", num);
return 0;
}
Output int value to console
#include <stdio.h>
int main(void)
{
printf("This is the number %d", 100);
return 0;
}
Print a int with a string
#include <stdio.h>
int main(void)
{
int num;
num = 100;
printf("%d is the value of num", num);
return 0;
}
Read and write int value in console
#include <stdio.h>
int main(void)
{
int i;
printf("Enter a number: ");
scanf("%d", &i);
printf("%d", i * i);
return 0;
}