Skip to content
Snippets Groups Projects
Commit 885f431d authored by Vignesh  C's avatar Vignesh C
Browse files

adding comment to source

parent 321fbeb2
No related branches found
No related tags found
No related merge requests found
two 0 → 100755
File added
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
//function prototype
int square(int n); int square(int n);
int input_num(); int input_num();
//main function
int main(){ int main(){
int hold; int hold;
hold = input_num(); hold = input_num();
int (*fnt)(int); int (*fnt)(int);
fnt = &square; fnt = &square;
printf("the square rooot: %d\n",fnt(hold));
printf("the square root: %d\n",fnt(hold));
} }
int square(int n){ int square(int n){ // the simple function to calculate square root
int res = n * n; int res = n * n;
return res; return res;
} }
//function to take a input from a user
int input_num(){ int input_num(){
char num[20]; char num[20];
printf("Enter the number for square: "); printf("Enter the numberrr for square: ");
fgets(num, sizeof(num), stdin); fgets(num, sizeof(num), stdin);
return atoi(num); return atoi(num); // Convert string input to integer and return it
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment