diff options
author | ankitjavalkar | 2015-09-14 12:28:41 +0530 |
---|---|---|
committer | ankitjavalkar | 2015-09-15 11:33:59 +0530 |
commit | 7a60f782995eed0352f3172f445bb35ae8ee6aa9 (patch) | |
tree | 91d6d12b0a494dd9777fd1120e92db5763bf009a /yaksh/c_cpp_files | |
parent | 32cde26f9807a29eb1fae0833e353212d43d7802 (diff) | |
download | online_test-7a60f782995eed0352f3172f445bb35ae8ee6aa9.tar.gz online_test-7a60f782995eed0352f3172f445bb35ae8ee6aa9.tar.bz2 online_test-7a60f782995eed0352f3172f445bb35ae8ee6aa9.zip |
Remove testapp dir, remove reference to testapp in paths, files
Diffstat (limited to 'yaksh/c_cpp_files')
-rwxr-xr-x | yaksh/c_cpp_files/main.cpp | 32 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main2.c | 30 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_array_check.cpp | 34 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_array_check_all.cpp | 34 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_array_sum.cpp | 34 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_blackJack.cpp | 41 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_check_digit.cpp | 32 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_count667.cpp | 42 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_count7.cpp | 42 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_fact.cpp | 32 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_greatest.cpp | 44 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_hello_name.c | 29 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_lessThan9.cpp | 38 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_mean.cpp | 38 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_palindrome.cpp | 32 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_roundTo10.cpp | 41 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_specialSum.cpp | 41 | ||||
-rwxr-xr-x | yaksh/c_cpp_files/main_within.cpp | 38 |
18 files changed, 654 insertions, 0 deletions
diff --git a/yaksh/c_cpp_files/main.cpp b/yaksh/c_cpp_files/main.cpp new file mode 100755 index 0000000..ebe1f08 --- /dev/null +++ b/yaksh/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/yaksh/c_cpp_files/main2.c b/yaksh/c_cpp_files/main2.c new file mode 100755 index 0000000..ccd1768 --- /dev/null +++ b/yaksh/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/yaksh/c_cpp_files/main_array_check.cpp b/yaksh/c_cpp_files/main_array_check.cpp new file mode 100755 index 0000000..ea34fdd --- /dev/null +++ b/yaksh/c_cpp_files/main_array_check.cpp @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> + +extern bool array_check(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) +{ + bool result; + int a[] = {1,2,3,0,0}; + result = array_check(a, 2); + printf("Input submitted to the function: {1, 2, 3, 0, 0} and index 2"); + check(false, result); + int b[] = {1,2,3,4,5}; + result = array_check(b, 3); + printf("Input submitted to the function: {1, 2, 3, 4, 5} and index 3"); + check(true, result); + printf("All Correct\n"); + return 0; +} diff --git a/yaksh/c_cpp_files/main_array_check_all.cpp b/yaksh/c_cpp_files/main_array_check_all.cpp new file mode 100755 index 0000000..140578e --- /dev/null +++ b/yaksh/c_cpp_files/main_array_check_all.cpp @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> + +extern bool array_check_all(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; + int a[] = {1,2,3,2,8}; + result = array_check_all(a); + printf("Input submitted to the function: {1, 2, 3, 2, 8}"); + check(false, result); + int b[] = {4,2,32,4,56}; + result = array_check_all(b); + printf("Input submitted to the function: {4, 2, 32, 4, 56}"); + check(true, result); + printf("All Correct\n"); + return 0; +} diff --git a/yaksh/c_cpp_files/main_array_sum.cpp b/yaksh/c_cpp_files/main_array_sum.cpp new file mode 100755 index 0000000..55b2ebf --- /dev/null +++ b/yaksh/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/yaksh/c_cpp_files/main_blackJack.cpp b/yaksh/c_cpp_files/main_blackJack.cpp new file mode 100755 index 0000000..cc54e78 --- /dev/null +++ b/yaksh/c_cpp_files/main_blackJack.cpp @@ -0,0 +1,41 @@ +#include <stdio.h> +#include <stdlib.h> + +extern int blackJack(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 = blackJack(11, 12); + printf("Input submitted to the function: 11, 12"); + check(12, result); + result = blackJack(15, 19); + printf("Input submitted to the function: 15, 19"); + check(19, result); + result = blackJack(10, 21); + printf("Input submitted to the function: 10, 21"); + check(21, result); + result = blackJack(31, 22); + printf("Input submitted to the function: 31, 22"); + check(0, result); + result = blackJack(91, 61); + printf("Input submitted to the function: 91, 61"); + check(0, result); + printf("All Correct\n"); + return 0; +} diff --git a/yaksh/c_cpp_files/main_check_digit.cpp b/yaksh/c_cpp_files/main_check_digit.cpp new file mode 100755 index 0000000..d3bf3d6 --- /dev/null +++ b/yaksh/c_cpp_files/main_check_digit.cpp @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <stdlib.h> + +extern bool check_digit(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) +{ + bool result; + result = check_digit(12, 23); + printf("Input submitted to the function: 12, 23"); + check(true, result); + result = check_digit(22, 11); + printf("Input submitted to the function: 121"); + check(false, result); + printf("All Correct\n"); + return 0; +} diff --git a/yaksh/c_cpp_files/main_count667.cpp b/yaksh/c_cpp_files/main_count667.cpp new file mode 100755 index 0000000..f146e8c --- /dev/null +++ b/yaksh/c_cpp_files/main_count667.cpp @@ -0,0 +1,42 @@ +#include <stdio.h> +#include <stdlib.h> + +extern int count667(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 arr[5] = {2,6,4,5,6}; + result = count667(arr); + printf("Input submitted to the function: [2, 6, 4, 5,6]"); + check(0, result); + int arr2[5] = {6,6,2,17,9}; + result = count667(arr2); + printf("Input submitted to the function: [6, 6, 2, 17, 9]"); + check(1, result); + int arr3[5] = {6,6,6,7,1}; + result = count667(arr3); + printf("Input submitted to the function: [6, 6, 7, 2, 1]"); + check(3, result); + int arr4[5] = {6,7,7,6,6}; + result = count667(arr4); + printf("Input submitted to the function: [6, 7, 7, 6, 6]"); + check(2, result); + printf("All Correct\n"); + return 0; +} diff --git a/yaksh/c_cpp_files/main_count7.cpp b/yaksh/c_cpp_files/main_count7.cpp new file mode 100755 index 0000000..982e930 --- /dev/null +++ b/yaksh/c_cpp_files/main_count7.cpp @@ -0,0 +1,42 @@ +#include <stdio.h> +#include <stdlib.h> + +extern int count7(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 arr[4] = {2,3,4,5}; + result = count7(arr); + printf("Input submitted to the function: [2, 3, 4, 5]"); + check(0, result); + int arr2[4] = {1,2,17,9}; + result = count7(arr2); + printf("Input submitted to the function: [1, 2, 17, 9]"); + check(0, result); + int arr3[4] = {7,9,2,1}; + result = count7(arr3); + printf("Input submitted to the function: [7, 9, 2, 1]"); + check(1, result); + int arr4[4] = {1,7,7,7}; + result = count7(arr4); + printf("Input submitted to the function: [1, 7, 7, 7]"); + check(3, result); + printf("All Correct\n"); + return 0; +} diff --git a/yaksh/c_cpp_files/main_fact.cpp b/yaksh/c_cpp_files/main_fact.cpp new file mode 100755 index 0000000..a4ff230 --- /dev/null +++ b/yaksh/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/yaksh/c_cpp_files/main_greatest.cpp b/yaksh/c_cpp_files/main_greatest.cpp new file mode 100755 index 0000000..6d0a7c2 --- /dev/null +++ b/yaksh/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/yaksh/c_cpp_files/main_hello_name.c b/yaksh/c_cpp_files/main_hello_name.c new file mode 100755 index 0000000..71b83a2 --- /dev/null +++ b/yaksh/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/yaksh/c_cpp_files/main_lessThan9.cpp b/yaksh/c_cpp_files/main_lessThan9.cpp new file mode 100755 index 0000000..722b4bb --- /dev/null +++ b/yaksh/c_cpp_files/main_lessThan9.cpp @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <stdlib.h> + +extern bool lessThan9(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 = lessThan9(10); + printf("Input submitted to the function: 10"); + check(false, result); + result = lessThan9(17); + printf("Input submitted to the function: 17"); + check(true, result); + result = lessThan9(16); + printf("Input submitted to the function: 16"); + check(true, result); + result = lessThan9(15); + printf("Input submitted to the function: 15"); + check(false, result); + printf("All Correct\n"); + return 0; +} diff --git a/yaksh/c_cpp_files/main_mean.cpp b/yaksh/c_cpp_files/main_mean.cpp new file mode 100755 index 0000000..21a4b1a --- /dev/null +++ b/yaksh/c_cpp_files/main_mean.cpp @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <stdlib.h> + +extern bool mean(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) +{ + bool result; + result = mean(11, 11, 11); + printf("Input submitted to the function: 11, 121, 11"); + check(true, result); + result = mean(16, 12, 9); + printf("Input submitted to the function: 16, 144, 9"); + check(true, result); + result = mean(19, 221, 9); + printf("Input submitted to the function: 19, 221, 9"); + check(false, result); + result = mean(34, 12, 3); + printf("Input submitted to the function: 11, 121, 11"); + check(false, result); + printf("All Correct\n"); + return 0; +} diff --git a/yaksh/c_cpp_files/main_palindrome.cpp b/yaksh/c_cpp_files/main_palindrome.cpp new file mode 100755 index 0000000..0e66928 --- /dev/null +++ b/yaksh/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; +} diff --git a/yaksh/c_cpp_files/main_roundTo10.cpp b/yaksh/c_cpp_files/main_roundTo10.cpp new file mode 100755 index 0000000..12c961d --- /dev/null +++ b/yaksh/c_cpp_files/main_roundTo10.cpp @@ -0,0 +1,41 @@ +#include <stdio.h> +#include <stdlib.h> + +extern int roundTo10(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 = roundTo10(10, 22, 39); + printf("Input submitted to the function: 10, 22, 39"); + check(70, result); + result = roundTo10(45, 42, 39); + printf("Input submitted to the function: 45, 42, 39"); + check(130, result); + result = roundTo10(7, 3, 9); + printf("Input submitted to the function: 7, 3, 9"); + check(20, result); + result = roundTo10(1, 2, 3); + printf("Input submitted to the function: 1, 2, 3"); + check(0, result); + result = roundTo10(30, 40, 50); + printf("Input submitted to the function: 30, 40, 50"); + check(120, result); + printf("All Correct\n"); + return 0; +} diff --git a/yaksh/c_cpp_files/main_specialSum.cpp b/yaksh/c_cpp_files/main_specialSum.cpp new file mode 100755 index 0000000..d614536 --- /dev/null +++ b/yaksh/c_cpp_files/main_specialSum.cpp @@ -0,0 +1,41 @@ +#include <stdio.h> +#include <stdlib.h> + +extern int specialSum(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 = specialSum(10, 2, 9); + printf("Input submitted to the function: 10, 2, 9"); + check(21, result); + result = specialSum(1, 21, 9); + printf("Input submitted to the function: 1, 21, 9"); + check(1, result); + result = specialSum(21, 2, 3); + printf("Input submitted to the function: 21, 2, 3"); + check(0, result); + result = specialSum(10, 2, 21); + printf("Input submitted to the function: 10, 2, 21"); + check(12, result); + result = specialSum(10, 2, 6); + printf("Input submitted to the function: 10, 2, 6"); + check(18, result); + printf("All Correct\n"); + return 0; +} diff --git a/yaksh/c_cpp_files/main_within.cpp b/yaksh/c_cpp_files/main_within.cpp new file mode 100755 index 0000000..50f9ad0 --- /dev/null +++ b/yaksh/c_cpp_files/main_within.cpp @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <stdlib.h> + +extern bool within(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) +{ + bool result; + result = within(12, 3, 20); + printf("Input submitted to the function: 12, 3, 20"); + check(true, result); + result = within(12, 13, 20); + printf("Input submitted to the function: 12, 13, 20"); + check(false, result); + result = within(29, 13, 120); + printf("Input submitted to the function: 29, 13, 120"); + check(true, result); + result = within(12, 12, 20); + printf("Input submitted to the function: 12, 3, 20"); + check(false, result); + printf("All Correct\n"); + return 0; +} |