Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- int n,itr;
- printf("Enter any four digit number\n");
- scanf("%d",&n);
- printf("\nEnter number of iteration you want to perform\n");
- scanf("%d",&itr);
- long int sqr=n,digit,first_two,first;
- for(int i=1 ; i<=itr; i++)
- {
- sqr *= sqr ;
- printf("\n%d iteration Square is %ld ",i,sqr);
- digit = log10(sqr) +1;
- if(digit == 8){
- first_two = sqr / 1000000;
- sqr /= 100;
- sqr -= (first_two * 10000);
- }
- else{
- first = sqr / 1000000;
- sqr /=100;
- sqr -= (first * 10000);
- }
- printf("random value extracted is %ld",sqr);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement