From 321fbeb25dd72bdaee9033529864e90687e244a8 Mon Sep 17 00:00:00 2001
From: Aarinvky <vigneshc15042001@gmail.com>
Date: Sun, 23 Mar 2025 16:16:23 +0000
Subject: [PATCH] square root attempt using function pointer

---
 sample.c |  5 -----
 two.c    | 30 ++++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 5 deletions(-)
 delete mode 100644 sample.c
 create mode 100644 two.c

diff --git a/sample.c b/sample.c
deleted file mode 100644
index 27a7e71..0000000
--- a/sample.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include<stdio.h>
-int main(){
-
-    printf("welcome to my c-programming projects");
-}
\ No newline at end of file
diff --git a/two.c b/two.c
new file mode 100644
index 0000000..794afd4
--- /dev/null
+++ b/two.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <time.h>
+#include <stdlib.h>
+
+int square(int n);
+int input_num();
+
+int main(){
+    int hold;
+    hold = input_num();
+    int (*fnt)(int);
+    fnt = &square;
+
+    printf("the square root: %d\n",fnt(hold));
+}
+
+
+int square(int n){
+    int res = n * n;
+    return res;
+}
+
+int input_num(){
+    char num[20];
+    printf("Enter the number for square: ");
+    fgets(num, sizeof(num), stdin);
+
+    return atoi(num);
+
+}
\ No newline at end of file
-- 
GitLab