summaryrefslogtreecommitdiff
path: root/testapp/c_cpp_files
diff options
context:
space:
mode:
Diffstat (limited to 'testapp/c_cpp_files')
-rwxr-xr-xtestapp/c_cpp_files/main.cpp32
-rwxr-xr-xtestapp/c_cpp_files/main2.c30
-rwxr-xr-xtestapp/c_cpp_files/main_array_sum.cpp34
-rwxr-xr-xtestapp/c_cpp_files/main_fact.cpp32
-rwxr-xr-xtestapp/c_cpp_files/main_greatest.cpp44
-rwxr-xr-xtestapp/c_cpp_files/main_hello_name.c29
-rwxr-xr-xtestapp/c_cpp_files/main_palindrome.cpp32
7 files changed, 233 insertions, 0 deletions
diff --git a/testapp/c_cpp_files/main.cpp b/testapp/c_cpp_files/main.cpp
new file mode 100755
index 0000000..ebe1f08
--- /dev/null
+++ b/testapp/c_cpp_files/main.cpp
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int add(int, int);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ int result;
+ result = add(0,0);
+ printf("Input submitted to the function: 0, 0");
+ check(0, result);
+ result = add(2,3);
+ printf("Input submitted to the function: 2 3");
+ check(5,result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main2.c b/testapp/c_cpp_files/main2.c
new file mode 100755
index 0000000..ccd1768
--- /dev/null
+++ b/testapp/c_cpp_files/main2.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int add(int, int, int);
+
+template <class T>
+void check(T expect,T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (0);
+ }
+}
+
+int main(void)
+{
+ int result;
+ result = add(0,0,0);
+ printf("Input submitted to the function: 0, 0, 0");
+ check(0, result);
+ result = add(2,3,3);
+ printf("Input submitted to the function: 2, 3, 3");
+ check(8,result);
+ printf("All Correct\n");
+}
diff --git a/testapp/c_cpp_files/main_array_sum.cpp b/testapp/c_cpp_files/main_array_sum.cpp
new file mode 100755
index 0000000..55b2ebf
--- /dev/null
+++ b/testapp/c_cpp_files/main_array_sum.cpp
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int array_sum(int []);
+
+template <class T>
+
+void check(T expect,T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ int result;
+ int a[] = {1,2,3,0,0};
+ result = array_sum(a);
+ printf("Input submitted to the function: {1, 2, 3, 0, 0}");
+ check(6, result);
+ int b[] = {1,2,3,4,5};
+ result = array_sum(b);
+ printf("Input submitted to the function: {1, 2, 3, 4, 5}");
+ check(15,result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_fact.cpp b/testapp/c_cpp_files/main_fact.cpp
new file mode 100755
index 0000000..a4ff230
--- /dev/null
+++ b/testapp/c_cpp_files/main_fact.cpp
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int factorial(int);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ int result;
+ result = factorial(0);
+ printf("Input submitted to the function: 0");
+ check(1, result);
+ result = factorial(3);
+ printf("Input submitted to the function: 3");
+ check(6, result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_greatest.cpp b/testapp/c_cpp_files/main_greatest.cpp
new file mode 100755
index 0000000..6d0a7c2
--- /dev/null
+++ b/testapp/c_cpp_files/main_greatest.cpp
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int greatest(int, int, int);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ int result;
+ result = greatest(1, 2, 3);
+ printf("Input submitted to the function: 1, 2, 3");
+ check(3, result);
+ result = greatest(5, 9, 2);
+ printf("Input submitted to the function: 5, 9, 2");
+ check(9, result);
+ result = greatest(7, 2, 4);
+ printf("Input submitted to the function: 7, 2, 4");
+ check(7, result);
+ result = greatest(11, 2, 45);
+ printf("Input submitted to the function: 11, 2, 45");
+ check(45, result);
+ result = greatest(2, 7, 0);
+ printf("Input submitted to the function: 2, 7, 0");
+ check(7, result);
+ result = greatest(9, 6, 5);
+ printf("Input submitted to the function: 9, 6, 5");
+ check(9, result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_hello_name.c b/testapp/c_cpp_files/main_hello_name.c
new file mode 100755
index 0000000..71b83a2
--- /dev/null
+++ b/testapp/c_cpp_files/main_hello_name.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+
+void check(char expect[], char result[])
+{
+ if (expect == result)
+ {
+ printf("Correct:expected %s got %s \n",expect,result);
+ }
+ else
+ {
+ printf("ERROR:expected %s got %s \n",expect,result);
+ exit (0);
+ }
+}
+
+int main(void)
+{
+ char result[20];
+ char A[20]=" pratham";
+ char B[20]=" sir";
+ result[20] = message(A);
+ printf("%s",result);
+ check("hello pratham", result);
+ result[20] = message(B);
+ check("hello sir",result);
+ printf("All Correct\n");
+}
diff --git a/testapp/c_cpp_files/main_palindrome.cpp b/testapp/c_cpp_files/main_palindrome.cpp
new file mode 100755
index 0000000..0e66928
--- /dev/null
+++ b/testapp/c_cpp_files/main_palindrome.cpp
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern bool palindrome(int);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ bool result;
+ result = palindrome(123);
+ printf("Input submitted to the function: 123");
+ check(false, result);
+ result = palindrome(121);
+ printf("Input submitted to the function: 121");
+ check(true, result);
+ printf("All Correct\n");
+ return 0;
+}