C Program to print an integer, its square, its cube.
- C program to print an integer.
#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
// reads and stores input
scanf("%d", &number);
// displays output
printf("You entered: %d", number);
return 0;
}
OUTPUT
Enter an integer: 15 You entered: 15
- C program to print square of an integer.
#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
// reads and stores input
scanf("%d", &number);
// displays output
printf("Its square: %d", number*number);
return 0;
}
OUTPUT
Enter an integer: 15 Its square: 225
- C program to print cube of an integer.
#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
// reads and stores input
scanf("%d", &number);
// displays output
printf("Its cube: %d", number*number);
return 0;
}
#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
// reads and stores input
scanf("%d", &number);
// displays output
printf("Its cube: %d", number*number);
return 0;
}
OUTPUT
Enter an integer: 15 Its cube: 3375
- C program to print an integer, its square, its cube.
#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
// reads and stores input
scanf("%d", &number);
// displays output
printf("You entered: %d", number);
printf("\nIts square: %d", number*number);
printf("\nIts cube: %d", number*number*number);
return 0;
}
OUTPUT
Enter an integer: 15 You entered: 15
Its square: 225
Its cube: 3375
Comments
Post a Comment