Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void main()
- {
- int x, a, b, n = 0, t[100];
- printf("\nPodaj liczbe naturalna: ");
- scanf("%d", &x);
- a = x;
- printf("\nPodaj baze reprezentacji (2-9): ");
- scanf("%d", &b);
- if(b<2 || b>9)
- {
- printf("\nNiepoprawna wartosc bazy!!\n");
- return;
- }
- while(x)
- {
- t[n] = x % b;
- n++;
- if(n >= 100) break;
- x = x / b;
- }
- printf("\n%d(10) = ", a);
- while(n)
- {
- n--;
- printf("%d", t[n]);
- }
- printf("(%d)\n\n\n", b);
- }
Advertisement
Add Comment
Please, Sign In to add comment