189k views
2 votes
Write a program that inputs the value 437 using each of the scanf integer conversion specifiers. Print each input value using all the integer conversion specifiers.

1 Answer

5 votes
Here's an example C program that inputs the value 437 using each of the scanf integer conversion specifiers and prints each input value using all the integer conversion specifiers:

```
#include

int main() {
int num1, num2, num3, num4, num5;
printf("Enter the value 437 using the %%d conversion specifier: ");
scanf("%d", &num1);
printf("Input value using %%d: %d\\", num1);
printf("Input value using %%i: %i\\", num1);
printf("Input value using %%o: %o\\", num1);
printf("Input value using %%u: %u\\", num1);
printf("Input value using %%x: %x\\", num1);

printf("Enter the value 437 using the %%i conversion specifier: ");
scanf("%i", &num2);
printf("Input value using %%d: %d\\", num2);
printf("Input value using %%i: %i\\", num2);
printf("Input value using %%o: %o\\", num2);
printf("Input value using %%u: %u\\", num2);
printf("Input value using %%x: %x\\", num2);

printf("Enter the value 437 using the %%o conversion specifier: ");
scanf("%o", &num3);
printf("Input value using %%d: %d\\", num3);
printf("Input value using %%i: %i\\", num3);
printf("Input value using %%o: %o\\", num3);
printf("Input value using %%u: %u\\", num3);
printf("Input value using %%x: %x\\", num3);

printf("Enter the value 437 using the %%u conversion specifier: ");
scanf("%u", &num4);
printf("Input value using %%d: %d\\", num4);
printf("Input value using %%i: %i\\", num4);
printf("Input value using %%o: %o\\", num4);
printf("Input value using %%u: %u\\", num4);
printf("Input value using %%x: %x\\", num4);

printf("Enter the value 437 using the %%x conversion specifier: ");
scanf("%x", &num5);
User Joseph Salisbury
by
8.1k points