Skip to content

Instantly share code, notes, and snippets.

@meshileya
Last active July 25, 2017 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meshileya/f690d754cdeab410d47fd4f511f2ae62 to your computer and use it in GitHub Desktop.
Save meshileya/f690d754cdeab410d47fd4f511f2ae62 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
char str[100];
int the_square;
int iterator, length, inputs;
char src[10];
char dest[12];
char newString[1];
char* ptr;
printf("Enter the value :");
scanf("%d", &inputs);
the_square=inputs;
for (iterator =0; iterator <50; iterator++){
the_square =the_square*the_square;
sprintf(str, "%d", the_square);
length = strlen(str);
if (length<8){
sprintf(newString, "%0.4s",strdup(str+1,10));
}else{
sprintf(newString, "%.4s",strdup(str+2,10));
}
printf("whatever %dth Number gives this square ==>%d which result to ==> %s\n", iterator,the_square, newString);
the_square = strtol(newString,&ptr, 10);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment