Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- char n[99999];
- long long k, i, prod = 1;
- printf("Enter the number: ");
- scanf("%s", n);
- printf("Enter the power: ");
- scanf("%lld", &k);
- if((n[strlen(n) - 1]) == '0' || (n[strlen(n) - 1]) == '1' || (n[strlen(n) - 1]) == '5' || (n[strlen(n) - 1]) == '6') printf("%c\n", (n[strlen(n) - 1]));
- else if((n[strlen(n) - 1]) == '2')
- {
- if(k % 4 == 0) printf("6\n");
- else if(k % 4 == 1) printf("2\n");
- else if(k % 4 == 2) printf("4\n");
- else if(k % 4 == 3) printf("8\n");
- }
- else if((n[strlen(n) - 1]) == '3')
- {
- if(k % 4 == 0) printf("1\n");
- else if(k % 4 == 1) printf("3\n");
- else if(k % 4 == 2) printf("9\n");
- else if(k % 4 == 3) printf("7\n");
- }
- else if((n[strlen(n) - 1]) == '4')
- {
- if(k % 2 == 0) printf("6\n");
- else if(k % 2 == 1) printf("4\n");
- }
- else if((n[strlen(n) - 1]) == '7')
- {
- if(k % 4 == 0) printf("1\n");
- else if(k % 4 == 1) printf("7\n");
- else if(k % 4 == 2) printf("9\n");
- else if(k % 4 == 3) printf("3\n");
- }
- else if((n[strlen(n) - 1]) == '8')
- {
- if(k % 4 == 0) printf("6\n");
- else if(k % 4 == 1) printf("8\n");
- else if(k % 4 == 2) printf("4\n");
- else if(k % 4 == 3) printf("2\n");
- }
- else if((n[strlen(n) - 1]) == '9')
- {
- if(k % 2 == 0) printf("1\n");
- else if(k % 2 == 1) printf("9\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment