From d0309942f71269488877d6b61a75fb575d8b4176 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 20:46:22 +0530 Subject: [PATCH 001/110] Create retangleofstar.cpp --- Akash Kumar/retangleofstar.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Akash Kumar/retangleofstar.cpp diff --git a/Akash Kumar/retangleofstar.cpp b/Akash Kumar/retangleofstar.cpp new file mode 100644 index 000000000..fc8278ddb --- /dev/null +++ b/Akash Kumar/retangleofstar.cpp @@ -0,0 +1,18 @@ +#include +// #include +#define repeat(x) for(int _iterator_i = 0; _iterator_i +using namespace std; +main_program{ +int n; +cin >> n; +// print the rectangle +repeat(n){ + +repeat(2*n){ +cout <<'*'; +} +cout << endl; +} +} From 6164248dd493e9c0460d35bfddcf174fba07dffd Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 20:47:53 +0530 Subject: [PATCH 002/110] Create Lofstar.cpp --- Akash Kumar/Lofstar.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Akash Kumar/Lofstar.cpp diff --git a/Akash Kumar/Lofstar.cpp b/Akash Kumar/Lofstar.cpp new file mode 100644 index 000000000..e21dab0f2 --- /dev/null +++ b/Akash Kumar/Lofstar.cpp @@ -0,0 +1,24 @@ +#include +#define repeat(x) for (int _iterator_i = 0; _iterator_i +using namespace std; +main_program{ +int n; +cin >> n; +// print the vertical bar +repeat(3*n){ +repeat(n){ +cout <<'*'; +} +cout << endl; +} +// print the horizontal bar +repeat(n){ + +repeat(4*n){ +cout <<'*'; +} +cout << endl; +} +} From 76936daa1fada1ffd21dd7674c4758b3cdbc88c5 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 20:50:26 +0530 Subject: [PATCH 003/110] Create sgpaandcgpa.cpp --- Akash Kumar/sgpaandcgpa.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Akash Kumar/sgpaandcgpa.cpp diff --git a/Akash Kumar/sgpaandcgpa.cpp b/Akash Kumar/sgpaandcgpa.cpp new file mode 100644 index 000000000..07dab1615 --- /dev/null +++ b/Akash Kumar/sgpaandcgpa.cpp @@ -0,0 +1,22 @@ +#include +#define repeat(x) for(int _iterator_i = 0; _iterator_i < x; _iterator_i++) +#include +#include +#define main_program int main() +using namespace std; +main_program{ +int N; cin >> N; +int weighted_sum = 0, sem_credits = 0; +repeat(N) { +char grade; int credit; +cin >> grade >> credit; +int num_grade = 10 - (grade - 'A'); +weighted_sum += credit * num_grade; +sem_credits += credit; +} +double curr_cpi ; +int credits_till ; +cin >> curr_cpi >> credits_till; +cout << fixed << setprecision(2) << weighted_sum * 1.0 / sem_credits << " "; +cout<< fixed << setprecision(2) << (curr_cpi * credits_till + weighted_sum )/(sem_credits + credits_till); +} From 52b1eeba8ddf7aa625f787861de7279f67c5c6b5 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 20:52:49 +0530 Subject: [PATCH 004/110] Create sumof2ismorethan1.c --- Akash Kumar/sumof2ismorethan1.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Akash Kumar/sumof2ismorethan1.c diff --git a/Akash Kumar/sumof2ismorethan1.c b/Akash Kumar/sumof2ismorethan1.c new file mode 100644 index 000000000..06afffd18 --- /dev/null +++ b/Akash Kumar/sumof2ismorethan1.c @@ -0,0 +1,22 @@ +#include + +int main() +{ + int a; + int b; + int c; + + + scanf("%d", &a); + scanf("%d", &b); + scanf("%d", &c); + + if((a+b)>c) + { + printf("1\n"); + }else{ + printf("0\n"); + } + + return 0; +} From c54cd6b3df915e0888965a48d003bb439ad20d0e Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 20:54:06 +0530 Subject: [PATCH 005/110] Create remainder1.c --- Akash Kumar/remainder1.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Akash Kumar/remainder1.c diff --git a/Akash Kumar/remainder1.c b/Akash Kumar/remainder1.c new file mode 100644 index 000000000..27d8b716b --- /dev/null +++ b/Akash Kumar/remainder1.c @@ -0,0 +1,15 @@ +#include +int main() +{ + int M, N; + scanf("%d", &M); + scanf("%d", &N); + if ((M%N)==1) + { + printf("1"); + } + else + { +printf("0"); + } +} From 10d73325b8aa6314de07dffd11b2f0f2e230200a Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 20:55:06 +0530 Subject: [PATCH 006/110] Create strictlyincreaseornot.c --- Akash Kumar/strictlyincreaseornot.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Akash Kumar/strictlyincreaseornot.c diff --git a/Akash Kumar/strictlyincreaseornot.c b/Akash Kumar/strictlyincreaseornot.c new file mode 100644 index 000000000..381463978 --- /dev/null +++ b/Akash Kumar/strictlyincreaseornot.c @@ -0,0 +1,14 @@ +#include +int main() +{ + int a,b,c; +scanf("%d %d %d", &a,&b, &c); + if(((a>b) && (b>c))||((c>b) && (b>a))) +{ +printf("1"); +} +else +{ +printf("0"); + } +} From 7078ca2aafc6634b1fee1bb531dcf739783b55f7 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 20:56:25 +0530 Subject: [PATCH 007/110] Create LowerUpperBothNonetriangularmatrix.c --- .../LowerUpperBothNonetriangularmatrix.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Akash Kumar/LowerUpperBothNonetriangularmatrix.c diff --git a/Akash Kumar/LowerUpperBothNonetriangularmatrix.c b/Akash Kumar/LowerUpperBothNonetriangularmatrix.c new file mode 100644 index 000000000..c64e2d9c5 --- /dev/null +++ b/Akash Kumar/LowerUpperBothNonetriangularmatrix.c @@ -0,0 +1,28 @@ +#include + +int main (){ + + int n, i, j, is_uppr=1, is_lowr=1, a; + + + scanf("%d",&n); + for( i=0; ii && a!=0)//Check for upper triangular condition + is_uppr = 0; + if( j Date: Tue, 4 May 2021 20:57:32 +0530 Subject: [PATCH 008/110] Create atleast3distinct.c --- Akash Kumar/atleast3distinct.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Akash Kumar/atleast3distinct.c diff --git a/Akash Kumar/atleast3distinct.c b/Akash Kumar/atleast3distinct.c new file mode 100644 index 000000000..7d94d8790 --- /dev/null +++ b/Akash Kumar/atleast3distinct.c @@ -0,0 +1,22 @@ + #include + int main() +{ +int curr=0; /* current value being read */ +int prev; /* previous value read */ +int num_distinct=0; /* number of distinct values read */ +prev = curr; +scanf ( "%d",&curr ); +num_distinct = 2; +while ( curr != -1 ) { +prev = curr; +scanf ( "%d", &curr ); +if ( prev != curr && curr != -1){ +num_distinct = num_distinct + 1; +} +} + if(num_distinct>3) + printf("1"); + else +printf("0"); + +} From 432310a6bd160ca1f2ab468289bf2a7ad18006ba Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 20:58:40 +0530 Subject: [PATCH 009/110] Create 2ndlargest.c --- Akash Kumar/2ndlargest.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Akash Kumar/2ndlargest.c diff --git a/Akash Kumar/2ndlargest.c b/Akash Kumar/2ndlargest.c new file mode 100644 index 000000000..914648c57 --- /dev/null +++ b/Akash Kumar/2ndlargest.c @@ -0,0 +1,44 @@ +#include + +int main() +{ + int a,b,d; + int c =0; + scanf("%d %d",&a,&b); + + if(a>b) + { + c=b; + + } + if(b>a) + { + c=a; + a=b; + b=c; + } + + for(;;) + { + scanf("%d",&b); + if(b==-1) + { + printf("%d",c); + break; + } + + if(b>a) + { + c=a; + a=b; + } + if(b>c && b Date: Tue, 4 May 2021 21:01:03 +0530 Subject: [PATCH 010/110] Create kthoccofn.c --- Akash Kumar/kthoccofn.c | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Akash Kumar/kthoccofn.c diff --git a/Akash Kumar/kthoccofn.c b/Akash Kumar/kthoccofn.c new file mode 100644 index 000000000..72eed9cd5 --- /dev/null +++ b/Akash Kumar/kthoccofn.c @@ -0,0 +1,55 @@ +/*Write a C function to find the kth occurrence of an odd integer in a sequence of non-negative integers, and then call your function from main. + +Your function should be according to the following declaration: + +int find_odd(int k); + +Input +You are given the input in two lines: + +The first line contains a positive integer k. +In the second line, you will be given a sequence of numbers. + +You have to find the kth occurrence of n in the sequence below. + +The second line consists of a sequence of non-negative integers, +terminated with a -1. The -1 is not part of the sequence. + +Output +If there are k odd numbers in the sequence, then output the kth +occurrence of odd in the sequence. Otherwise, output -1. +*/ + +#include + +void find_odd ( int k ) +{ + int odd_count=0; + int curr; + + + scanf("%d",&curr); + while ( curr != -1 ){ + if ( curr % 2 == 1 ){ + odd_count = odd_count+1; + if ( odd_count == k ){ + printf ( "%d\n", curr ); + return ; + } + } + scanf ( "%d", &curr ); + } + + + printf ( "-1\n" ); + return ; +} +int main() +{ + int k; + + scanf("%d",&k); + find_odd(k); + + return 0; +} From 9e727059dc838b9f12fa9112176deca7b1dd0da4 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:02:13 +0530 Subject: [PATCH 011/110] Create movingaverage.c --- Akash Kumar/movingaverage.c | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Akash Kumar/movingaverage.c diff --git a/Akash Kumar/movingaverage.c b/Akash Kumar/movingaverage.c new file mode 100644 index 000000000..9032886ab --- /dev/null +++ b/Akash Kumar/movingaverage.c @@ -0,0 +1,45 @@ +/* In this question, you have to output the "moving average" of a +sequence of non-negative numbers. The moving average is the sequence +of averages of the last 2 entries. For the first number, no average +is output. + +For example, if the sequence of numbers is + +a1, a2, a3, a4, a5 + +then the 2-moving average is + +(a1+a2)/2, (a2+a3)/2, (a3+a4)/2, (a4+a5)/2 + + +Input +----- + +The input is a sequence of non-negative floating point numbers, +terminated by a -1. The -1 is not part of the sequence. There will be +at least 3 numbers in the sequence. + +Output +-------------------------------------------------------------------------------------------- +You have to output the moving average of the sequence. The output +should be printed correct to one digit after the decimal. +*/ + +#include +int main() +{ +float first; +float second; +float curr; +scanf ( "%f", &first ); +scanf ( "%f", &second ); +printf ( "%.1f ", (first+second)/2); +scanf ( "%f", &curr ); +while ( curr != -1 ){ +first = second; +second = curr; +printf ( "%.1f ", (first+second)/2); +scanf ( "%f", &curr ); +} +return 0; +} From dfd936afa07506c6e1866f9cba71fbcf87252dfa Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:03:20 +0530 Subject: [PATCH 012/110] Create allfactlessthann.c --- Akash Kumar/allfactlessthann.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Akash Kumar/allfactlessthann.c diff --git a/Akash Kumar/allfactlessthann.c b/Akash Kumar/allfactlessthann.c new file mode 100644 index 000000000..2c4aaf3bb --- /dev/null +++ b/Akash Kumar/allfactlessthann.c @@ -0,0 +1,32 @@ +/*Write a C program to list all the factorial numbers less than or equal +to an input number n. + +A number N is called a factorial number if it is the factorial of a +positive integer. For example, the first few factorial numbers are + + 1, 2, 6, 24, 120, ... + +*Note* - We do not list the factorial of 0. + +Input +----- +A positive integer, say n. + +Output +------ +All factorial numbers less than or equal to n. */ +#include + int main() + { +int n; +int i=1; +long factorial=1; +scanf("%d",&n); +while(factorial <= n){ +printf("%ld ", factorial); +i++; +factorial *= i; +} +printf("\n"); +return 0; + } From 9560cc4ad3efec107736eec785e2dd965dbd7d37 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:05:50 +0530 Subject: [PATCH 013/110] Create largestintnotoccorin2ndarray.c --- Akash Kumar/largestintnotoccorin2ndarray.c | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Akash Kumar/largestintnotoccorin2ndarray.c diff --git a/Akash Kumar/largestintnotoccorin2ndarray.c b/Akash Kumar/largestintnotoccorin2ndarray.c new file mode 100644 index 000000000..0698c25dc --- /dev/null +++ b/Akash Kumar/largestintnotoccorin2ndarray.c @@ -0,0 +1,59 @@ +/* Given two arrays of integers output the largest number in the +first array not present in the second one. + +Input: + +The first line contains the size of the first array. +Next line give the contents of the first array. +Next line contains the size of the second array. +Next line give the contents of the second array. + +Output Format: +Output must be a single number which is the largest number occurring +in the first array that does not occur in the second. In case there is +no such number, output 0. + +Variable Constraints: +The sizes of the arrays are smaller than 20. +Each array entry is an integer which fits an int data type. */ + +#include +#define MAX 20 +int read_array(int arr[]) +{ +int i, n; +scanf("%d", &n); +for (i = 0; i < n; i++) +scanf("%d", &arr[i]); +return n; +} +int present(int arr[], int n, int elt) { +int i; +for (i = 0; i < n; i++) { +if (arr[i] == elt) { +return 1; +} +} +return 0; +} +int main() { +int arr1[MAX], n1; +int arr2[MAX], n2; +n1 = read_array(arr1); +n2 = read_array(arr2); +int i, small_np = 0, flag = 0; +for (i = 0; i < n1; i++) { +if (!present(arr2, n2, arr1[i])) { +if (!flag || (small_np < arr1[i]) ) { +flag = 1; +small_np = arr1[i]; +} +} +} +if (flag) { +printf("%d", small_np); +} else { +printf("0"); +} + return 0; +} From 4b79da2af9614c1dc3656b93ac67460711e3ae29 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:06:53 +0530 Subject: [PATCH 014/110] Create distinctnoinsequence.c --- Akash Kumar/distinctnoinsequence.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Akash Kumar/distinctnoinsequence.c diff --git a/Akash Kumar/distinctnoinsequence.c b/Akash Kumar/distinctnoinsequence.c new file mode 100644 index 000000000..c3bacddad --- /dev/null +++ b/Akash Kumar/distinctnoinsequence.c @@ -0,0 +1,30 @@ +#include +#define SIZE 1000 +int main() +{ +int arr[SIZE]; +int i; +int j; +int count=0; +int n; +scanf("%d",&n); +for(i=0;i=0;j--){ +if(arr[j] == arr[i]){ +found=1; +break; +} +} +if ( found == 0 ){ /* arr[i] is a new element */ +count = count + 1; +} +} +printf("%d",count); +return 0; +} From 7609d1adf9938805a36d0467527ebbb917932c96 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:08:28 +0530 Subject: [PATCH 015/110] Create replaceofChar.c --- Akash Kumar/replaceofChar.c | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Akash Kumar/replaceofChar.c diff --git a/Akash Kumar/replaceofChar.c b/Akash Kumar/replaceofChar.c new file mode 100644 index 000000000..638697881 --- /dev/null +++ b/Akash Kumar/replaceofChar.c @@ -0,0 +1,71 @@ +/* Write a program that replaces the occurence of a given character (say c) +in a primary string (say PS) with another string (say s). + +Input: +The first line contains the primary string (PS) +The next line contains a character (c) +The next line contains a string (s) + +Output: +Print the string PS with every occurence of c replaced by s. */ +#include + int length(char *s) + { +int i=0; +while(s[i]!='\0') +{ +i++; +} +return i; + } + void Replace(char *str, char *sub, int start , int end) + { +int i=-1; +int len = length(str); +char temp[100]; +do +{ +i++; +temp[i]=str[i]; +} while(i!=len); +int sublen=length(sub); +int j = start; +for(i=0;i=0) +{ +start=i; +end=val; +Replace(str,subs1,start,end); +i=start+length(subs1); +} + } + printf("%s",str); + return 0; + } From e02cf7a4eb6df7c8031ac9ec3a1ff0276bdba7cf Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:09:58 +0530 Subject: [PATCH 016/110] Create CollatzFunction.c --- Akash Kumar/CollatzFunction.c | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Akash Kumar/CollatzFunction.c diff --git a/Akash Kumar/CollatzFunction.c b/Akash Kumar/CollatzFunction.c new file mode 100644 index 000000000..3d40ad9dc --- /dev/null +++ b/Akash Kumar/CollatzFunction.c @@ -0,0 +1,49 @@ +/* The Collatz function is defined for a positive integer n as follows. + +f(n) = 3n+1 if n is odd + + = n/2 if n is even + = 1 if n=1 + + +We consider the repeated application of the Collatz function starting with a given integer n, as follows: + +f(n), f(f(n)), f(f(f(n))), … + + +It is conjectured that no matter which positive integer n you start from, this sequence eventually will have 1 in it. It has been verified to hold for numbers up to 5 × 260 [Wikipedia: Collatz Conjecture]. */ + +#include +int x =0; +void collatz_repeat(int n) +{ + + if ( n == 1 ) + { + if(x==0) + printf("1"); + else + return; + + } + + else{ + x=1; + if ( n % 2 == 1 ) { + printf("%d ",3*n+1 ); + collatz_repeat(3*n+1); + }else{ + printf("%d ",n/2); + collatz_repeat(n/2); + } + } +} + + +int main() +{ + int n; + scanf("%d",&n); + collatz_repeat(n); + return 0; +} From 9a3cb0a3f8c183ed63d566208ed0f3e523482641 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:11:16 +0530 Subject: [PATCH 017/110] Create fib_problem.c --- Akash Kumar/fib_problem.c | 68 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Akash Kumar/fib_problem.c diff --git a/Akash Kumar/fib_problem.c b/Akash Kumar/fib_problem.c new file mode 100644 index 000000000..7102118a8 --- /dev/null +++ b/Akash Kumar/fib_problem.c @@ -0,0 +1,68 @@ +/* A sequence of positive numbers is defined as : + + f(n) = f(n-1) + f(n-2) for all n >2 + +and f(1) ,f(2) are defined explicitly. + +For example : If we define f(1) = 1 and f(2) =2 + +Then the sequence obtained is 1 2 3 5 8 13......... + +The distance of two numbers a and b is defined as the |a-b| or the positive difference of the numbers. +For example: Distance of 2 and 3 is |2-3|=1 . + Distance of 14 and 9 is |14-9| = 5 + +In this question you will be given the first two elements of the sequence separated by the space and in next line a number let say p. +You need to output the minimum distance of p to the elements of sequence. + +Example : +I/P : 1 1 + 6 +So, the sequence is 1 1 2 3 5 8 13....... +Minimum distance of 6 to sequence is |5-6| = 1 +O/P : 1 +Constraints : +First two elements(f(1) and f(2)) of the sequence are in monotonically increasing order and are positive integers. +p is an integer. */ + +#include +#include +int min(int a, int b); +int fib(int m, int n, int p); +int main() +{ + int m,n,p,x,z; + scanf("%d %d %d",&m,&n,&p); + if(p<=m) + { + printf("%d",m-p); + exit(1); + } + if(p>m && p<=n) + { + z=min(p-m,n-p); + printf("%d",z); + exit(1); + } + + x = fib(m,n,p); + printf("%d",x); + return 0; +} +int min(int a, int b) +{ + if(a>b) + return b; + else + return a; +} + +int fib(int m, int n, int p) + { + int x = m+n; + if(x Date: Tue, 4 May 2021 21:12:46 +0530 Subject: [PATCH 018/110] Create reversestringbyrecursion.c --- Akash Kumar/reversestringbyrecursion.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Akash Kumar/reversestringbyrecursion.c diff --git a/Akash Kumar/reversestringbyrecursion.c b/Akash Kumar/reversestringbyrecursion.c new file mode 100644 index 000000000..a77197812 --- /dev/null +++ b/Akash Kumar/reversestringbyrecursion.c @@ -0,0 +1,19 @@ +/* Write a recursive program to print the reverse of the string ending with 0. +Input : String ending with 0 +Output : Reverse of the string without 0. + +Example : I/P : abcd0 + O/P: dcba + */ + +#include +void revstr() { +int ch = getchar(); +if (ch == '0') return; +revstr(); +putchar(ch); +} +int main() { +revstr(); +return 0; +} From 254dd6f91349ffa3f0940ea1de69e27fe4ca603d Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:14:25 +0530 Subject: [PATCH 019/110] Create noOfmatchingPositioninAnagram.c --- Akash Kumar/noOfmatchingPositioninAnagram.c | 71 +++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Akash Kumar/noOfmatchingPositioninAnagram.c diff --git a/Akash Kumar/noOfmatchingPositioninAnagram.c b/Akash Kumar/noOfmatchingPositioninAnagram.c new file mode 100644 index 000000000..639e8f1fc --- /dev/null +++ b/Akash Kumar/noOfmatchingPositioninAnagram.c @@ -0,0 +1,71 @@ +/* We say that a string 's' is an anagram of another string 't' if the +letters in 's' can be rearranged to form 't'. + +For example, "butterfly" is an anagram of "flutterby", since a +rearrangement of the first word results in the second. + +We say that a position 'i' in 's' and 't' match, if 's' is an anagram of +'t', and s[i]==t[i]. + +In this question, you will be given two words, 's' and 't'. You have +to output the number of matching positions if s is an anagram of t, +and -1 if s is not an anagram of t. + +Input +----- +The input consists of two lines. The first line contains the first +string, with length <= 100 characters. The second line contains the +second string, with length <= 100 characters. + +Output +------ +If the first string is an anagram of the second string, then output +the number of matching positions. Otherwise, print -1. + +Sample Input 1 +-------------- +butterfly +flutterby + +Sample Output 1 +--------------- +2 + +*/ + +#include +#include +int freq(char s[], char c) +{ +int i; +int count=0; +for(i=0; s[i] != '\0'; i++){ +if(s[i] == c){ +count++; +} +} +return count; +} +int main() +{ +char s[100]; +char t[100]; +int i,x; +int counter=0; +scanf("%s",s); +scanf("%s",t); +for(i=0;i<26;i++){ +if(freq(s,'a'+i) != freq(t,'a'+i)){ +printf("-1"); +return 0; +} +} +x= strlen(s); +for(i=0;i Date: Tue, 4 May 2021 21:16:26 +0530 Subject: [PATCH 020/110] Create Nodeproblem.c --- Akash Kumar/Nodeproblem.c | 175 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 Akash Kumar/Nodeproblem.c diff --git a/Akash Kumar/Nodeproblem.c b/Akash Kumar/Nodeproblem.c new file mode 100644 index 000000000..fd0bd75d1 --- /dev/null +++ b/Akash Kumar/Nodeproblem.c @@ -0,0 +1,175 @@ +/* A graph is abstractly a collection of vertices which are labelled by +non-negative integers, and a collection of edges. A graph called an +undirected graph if we talk of merely the presence of an edge between +vertices i and j, rather than its direction. + +For example, the following is a graph: + + +In this problem, you are given the edges in an undirected graph. An +edge is a pair of non-negative integers (i, j) which indicates that +the vetex i is connected to vetex j by an edge. + +Afterwards, you will be given a vertex number n. You have to output +the list of vertices which are connected n by an edge, in the order in +which the edges were input. + +Input + +You are given the following. + +1. The first line contains an integer, E, between 1 and 1000 + +2. This is followed by E lines, where each containing a pair of +numbers i and j where i and j are both non-negative integers <= +34,000. No edge will be listed more than once. + +3. The last line contains a non-negative integer n <= 34,000. n is +assured to be a vertex listed in one of the E lines in part (2). + +Output + +You have to output the list of nodes to which n has an edge, in the +order in which the edges were input, one line for each vertex. + +*/ + +#include +#include + + + struct node + { + int vertex; + struct node *next; + }; + +struct list_entry +{ + +struct node *head; + +struct node *tail; + +}; + +struct list_entry list_entries[34000]; + +void init_list_entries() + { int i; for ( i=0 ; i<100 ; i++ ) + { + list_entries[i].head = list_entries[i].tail = + NULL; + } + } + +struct node * make_node ( int data ) +{ + + struct node *temp = (struct node *)malloc(sizeof(struct node)); + + temp -> vertex = data; + + temp -> next = NULL; + + return temp; + +} + +void insert_at_end(int a, int b) + + { + + struct node *node1; + + struct node *node2; + + node1 = make_node (a); + + if(list_entries[b].head == NULL) + { + + list_entries[b].head = node1; + + list_entries[b].tail = node1; + } + + else + { + + list_entries[b].tail->next = node1; + + list_entries[b].tail = node1; + } + + node2 = make_node(b); + + if(list_entries[a].head == NULL) + { + + list_entries[a].head = node2; + + list_entries[a].tail = node2; + + } + else + { + + list_entries[a].tail->next = node2; + + list_entries[a].tail = node2; + + } + + return; + +} + +void print_adjacent_vertices_of(int n) + +{ + + struct node *current = list_entries[n].head; while(current != NULL) + { + + printf("%d\n",current->vertex); + + current = current->next; + + } + + return; + +} + +int main() + +{ + + int num_edges; + + int a; + + int b; + + int n; + + int i=0; + + scanf("%d", &num_edges); + + for ( i=0; i Date: Tue, 4 May 2021 21:17:58 +0530 Subject: [PATCH 021/110] Create longestoccinstring.c --- Akash Kumar/longestoccinstring.c | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Akash Kumar/longestoccinstring.c diff --git a/Akash Kumar/longestoccinstring.c b/Akash Kumar/longestoccinstring.c new file mode 100644 index 000000000..5d1ed670f --- /dev/null +++ b/Akash Kumar/longestoccinstring.c @@ -0,0 +1,58 @@ +/* In a string, a "run" is a substring with consisting of consecutive +occurrences of the same character. For example, the string +"mississippi" contains the following runs - "ss", "ss" and "pp". + +In this question, given a string, you have to output the length of the +longest run in the string. + +Input +----- +A string, having length at most 100. The string is guaranteed to have +at least one run. + +Output +------ +The length of the longest run in the string. + +Sample Input +------------ +abbaaacccc + +Sample Output +------------- +4 +*/ + +#include +/* Find maximum run length in a string */ +int max_run_length(char s[]) +{ +int maxlen=0; +int curr_run=0; +char curr_char; +int i=0; +for(i=0; s[i]!='\0'; i++){ +/* Calculate the length of the current run */ +curr_char = s[i]; +curr_run = 0; +while(s[i] == curr_char && s[i] != '\0'){ +i++; +curr_run++; +} +i--; +/* If the current run is longer than maxrun, reset */ +if(curr_run > maxlen){ +maxlen = curr_run; +} +} +return maxlen; +} +int main() +{ +char s[100]; +int result; +scanf("%s",s); +result = max_run_length(s); +printf("%d", result); +return 0; +} From 3bc5a75eef03fe0a41728a1f3a789d6b8fee4f2f Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:19:17 +0530 Subject: [PATCH 022/110] Create SortofDatabase.c --- Akash Kumar/SortofDatabase.c | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Akash Kumar/SortofDatabase.c diff --git a/Akash Kumar/SortofDatabase.c b/Akash Kumar/SortofDatabase.c new file mode 100644 index 000000000..13cd12908 --- /dev/null +++ b/Akash Kumar/SortofDatabase.c @@ -0,0 +1,65 @@ +/* Create a database of students using structures, where in each entry of the database will have the following fields: +a name, which is a string with at most 128 characters +their marks in physics which is an int between 0 and 100 +their marks in chemistry which is an int number between 0 and 100 +their marks in mathematics which is an int number between 0 and 100 +You have to output a list of students in the following order. +if a student 'A' has lower marks in physics than a student 'B', then A's data is listed before B. +If A and B have the same physics marks and A has lower chemistry marks than B, then A is listed before B. +If A and B have the same marks in physics and chemistry, and A has lower marks in mathematics than B, then A is listed before B. +If all marks are equal and A's name precedes B's name in the dictionary order, then A is listed before B. +. + +Input Format : +First line contains the number of students n, where 1<=n<=100. +In following n lines each line contains(space separated) a name and their respective marks in physics, chemistry, maths, where 0<=marks<=100. + +Output Format : +Sorted database of n lines +*/ + +#include +#include +struct student{ +char name[20]; +int phy,che,math; +}; +typedef struct student student; +void print(student *s,int n){ +int i; +for(i=0;iphy; +float r = ((student *)q)->phy; +if((l-r)!=0) return (l-r); +else{ +l = ((student *)p)->che; +r = ((student *)q)->che; +if((l-r)!=0) return(l-r); +else{ +l = ((student *)p)->math; +r = ((student *)q)->math; +return (l-r); +} } +} +int main(){ +int i,n; +scanf("%d",&n); +student *student_info= (student *)malloc(sizeof(student)*n); +for(i=0;i Date: Tue, 4 May 2021 21:21:20 +0530 Subject: [PATCH 023/110] Create DeleteallaftercertainelementinLinkedList.c --- ...DeleteallaftercertainelementinLinkedList.c | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Akash Kumar/DeleteallaftercertainelementinLinkedList.c diff --git a/Akash Kumar/DeleteallaftercertainelementinLinkedList.c b/Akash Kumar/DeleteallaftercertainelementinLinkedList.c new file mode 100644 index 000000000..6cca43547 --- /dev/null +++ b/Akash Kumar/DeleteallaftercertainelementinLinkedList.c @@ -0,0 +1,115 @@ +/* You are given a sequence of integers terminated with a -1. The -1 is +not part of the input sequence. + + +Next, you are given a positive number N. + +You have to create a linked list with the input sequence of integers +as entries. You can use the following structure. + + struct node{ + int data; + struct node *next; + }; + + +Now, you have to delete all but the last N elements from the linked +list, and print the resulting list. (i.e. The resulting list will +consist of only the last N elements from the list.) + + +If N is longer than the length of the linked list, you must print -1. + +While printing, the entries of the list must be separated by a single +space. + +Sample Input +------------ +3 4 5 6 -1 +1 + +Sample Output +------------- +6 +*/ + +#include +#include +struct node { +int data; +struct node *next; +}; +int list_length; +struct node* create_node ( int n ) +{ +struct node *new_node; +new_node = (struct node *) malloc ( sizeof(struct node) ); +new_node->data = n; +new_node->next = NULL; +return new_node; +} +struct node* create_list ( struct node *head ) +{ +int number; +struct node *current_node, *new_node; +scanf("%d",&number); +if(number != -1){ +head = create_node ( number ); +current_node = head; +list_length++; +scanf ( "%d", &number ); +while ( number != -1 ){ +new_node = create_node ( number ); +current_node->next = new_node; +list_length++; +current_node = new_node; /* advance to next node */ +scanf ( "%d", &number ); +} +} +return head; +} +/* Delete the first num nodes from the list */ +struct node *delete_first ( int num, struct node *head ) +{ +int i=1; +struct node *current_node = head; +struct node *next_node; +while ( i <= num ) { +next_node = current_node->next; +free(current_node); +current_node = next_node; +i++; +} +head = current_node; +return head; +} +void print_list ( struct node *head ) +{ +struct node * current_node; +if ( head == NULL ){ +return; +} +current_node = head; +while ( current_node != NULL ) { +printf ( "%d ", current_node->data ); +current_node = current_node->next; +} +printf("\n"); +return; +} +int main() +{ +int number; +int pruned_length=0; +struct node *head; +head = create_list ( head ); +scanf("%d", &pruned_length); +if(pruned_length > list_length){ +printf ( "-1\n" ); +return 0; +}else{ +head=delete_first(list_length-pruned_length, head); +print_list(head); +} +return 0; +} From c07ba5854620fb65d7010a5390c08689f6c002b9 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:23:28 +0530 Subject: [PATCH 024/110] Create DoublyLinkedlistproblem.c --- Akash Kumar/DoublyLinkedlistproblem.c | 163 ++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 Akash Kumar/DoublyLinkedlistproblem.c diff --git a/Akash Kumar/DoublyLinkedlistproblem.c b/Akash Kumar/DoublyLinkedlistproblem.c new file mode 100644 index 000000000..f668c3f35 --- /dev/null +++ b/Akash Kumar/DoublyLinkedlistproblem.c @@ -0,0 +1,163 @@ +/* In this question, you have to write code to remove the first node in a doubly linked list containing a specified number. The code to create the linked list is already given. The main() function calls a function removeData(head,tail,n) to remove the first node containing n from the linked list. + +Complete the code by writing the missing function. You can also write additional functions which you may need. + +Input Format +You will be given a positive number N in the first line. + +This will be followed by a line containing N integers. + +This will be followed by an integer M. + +Output format +The output will be the list after deleting M. Note that you do not have to add any additional code to print the list - once you code the removeData() function, the code will print the contents of the remaining list. + */ + +#include +#include + +struct DoublyLinkedList{ + int data; + struct DoublyLinkedList *prev; + struct DoublyLinkedList *next; +}; + +/* + -------------------------- + Create a new node + -------------------------- +*/ +struct DoublyLinkedList *createNode(int n) +{ + struct DoublyLinkedList *newNodeptr; + newNodeptr = (struct DoublyLinkedList*) + malloc (sizeof(struct DoublyLinkedList)); + newNodeptr->data = n; + newNodeptr->prev = NULL; + newNodeptr->next = NULL; + return newNodeptr; +} + +/* + -------------------------------- + add a node at the end of a doubly linked list. + Tailptr is the address of the pointer to the end of the current list. + After adding the node, tail points to the new node inserted. + -------------------------------- +*/ +void appendNode ( struct DoublyLinkedList **tailptr, int n ) +{ + struct DoublyLinkedList *newNode; + newNode = createNode ( n ); + newNode->prev=*tailptr; + + (*tailptr)->next = newNode; + + *tailptr=newNode; +} + +void initializeList ( + struct DoublyLinkedList **headptr, + struct DoublyLinkedList **tailptr, + int n) +{ + struct DoublyLinkedList *newNode; + newNode=createNode(n); + *headptr=newNode; + *tailptr=newNode; + return; +} + +void printList( + struct DoublyLinkedList *head, + struct DoublyLinkedList *tail) +{ + struct DoublyLinkedList *curr=head; + + while ( curr != NULL ){ + if(curr->next!=NULL) + printf("%d,",curr->data); + else printf("%d",curr->data); + curr = curr->next; + } + + return; +} + +/* + -------------------------------- + remove the node that ptr points to. + After removing the first node, we should reset head. + After removing the last node, we should reset tail. + -------------------------------- +*/ +void removeNode ( + struct DoublyLinkedList **headptr, + struct DoublyLinkedList **tailptr, + struct DoublyLinkedList *ptr) +{ + if ( ptr == *headptr ){ + *headptr = ptr->next; + (*headptr)->prev = NULL; + }else{ + if ( ptr == *tailptr ) { + *tailptr = ptr->prev; + (*tailptr)->next=NULL; + }else{ + ptr->prev->next = ptr->next; + ptr->next->prev = ptr->prev; + } + } + free ( ptr ); + ptr = NULL; + return; +} + +void removeData ( + struct DoublyLinkedList **headptr, + struct DoublyLinkedList **tailptr, + int n) +{ + struct DoublyLinkedList *curr; + curr = *headptr; + + while ( curr != NULL && curr->data != n ){ + curr = curr->next; + } + if ( curr != NULL ){ + removeNode(headptr, tailptr, curr); + } + return; +} + + +int main() +{ + int n; + int i=0; + int m; + struct DoublyLinkedList *head, *tail; + + scanf("%d",&n); + + if ( n <= 0 ){ + return 0; + } + + scanf("%d",&m); + initializeList(&head,&tail,m); + + + for(i=1;i Date: Tue, 4 May 2021 21:25:14 +0530 Subject: [PATCH 025/110] Create MODuloproblem.c --- Akash Kumar/MODuloproblem.c | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Akash Kumar/MODuloproblem.c diff --git a/Akash Kumar/MODuloproblem.c b/Akash Kumar/MODuloproblem.c new file mode 100644 index 000000000..dde7aee80 --- /dev/null +++ b/Akash Kumar/MODuloproblem.c @@ -0,0 +1,49 @@ +/* You are given a non-negative number less than or equal to 100000000 (1 +followed by 8 zeroes). You have to divide the number into the +following components, and print them in the following order. + +1. The part of the number which is less than a thousand. +2. The part of the number which is between a thousand and a lakh +3. The part of the number which is between a lakh and a crore + +and so on. You should terminate printing when no higher power of 10 is +present to be printed. + +For example, suppose the input number is + +134847 + +Then the output should be +847 +34 +1 + +The question can be done with or without using arrays. + +Hint: Using % (that is, the modulo operator) and / (the division +operator on integers) is helpful in solving this question. + +*/ + +#include + +int main() +{ + int n; /* the upper limit is lower than the max int value, + so no checks needed */ + int divisor; + + scanf("%d", &n); + + divisor=1000; + printf("%d\n", n % divisor); + n = n/divisor; + + divisor=100; + while ( n != 0 ){ + printf ( "%d\n", n % divisor ); + n = n/divisor; + } + + return 0; +} From d1951dccff49d5f58368f63ad7eb3a4bd9bfdddb Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:26:47 +0530 Subject: [PATCH 026/110] Create NoofInversion.c --- Akash Kumar/NoofInversion.c | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Akash Kumar/NoofInversion.c diff --git a/Akash Kumar/NoofInversion.c b/Akash Kumar/NoofInversion.c new file mode 100644 index 000000000..235927f08 --- /dev/null +++ b/Akash Kumar/NoofInversion.c @@ -0,0 +1,71 @@ +/* You are given a sequence of positive integers, terminating in a +-1. (The -1 is not part of the sequence, it is used to denote the end +of the input.) There are at most 100 integers in the sequence. + +An inversion is a pair of integers (i,j) such that i occurs before j +in the sequence, but i > j. + +You have to output the number of inversions in the input sequence. + + +Sample Input 1 +------------- +1 3 2 -1 + + +Sample Output 1 +-------------- +1 + +Explanation for Sample 1 +------------------------ +The pairs of integers in the sequence are (1,3), (1,2) and +(3,2). Among these, (3,2) is the only inversion. + + +Sample Input 2 +--------------- +20 20 5 4 -1 + +Sample Output 2 +---------------- +5 + +Explanation for Sample 2 +------------------------ +The pairs of integers are (20,20), (20,5), (20,4), (20,5), (20,4) and +(5,4). All except (20,20) are inversions. + +*/ + +#include + + + +int main() +{ + + int sequence[100]; + int i,j,n; + int length=0; + int inversion_count=0; + + for(i=0;i<100;i++){ + scanf("%d",&n); + if ( n == -1 ){ + break; + } + sequence[i] = n; + length = length+1; + } + + for(i=0;i sequence[j] ){ + inversion_count = inversion_count+1; + } + } + } + printf("%d\n",inversion_count); + return 0; +} From eba0dacc761f09ff380c64691f3afbd504cfeb27 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:28:02 +0530 Subject: [PATCH 027/110] Create EncriptedformofStringProblem.c --- Akash Kumar/EncriptedformofStringProblem.c | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Akash Kumar/EncriptedformofStringProblem.c diff --git a/Akash Kumar/EncriptedformofStringProblem.c b/Akash Kumar/EncriptedformofStringProblem.c new file mode 100644 index 000000000..0f6a11524 --- /dev/null +++ b/Akash Kumar/EncriptedformofStringProblem.c @@ -0,0 +1,38 @@ +/* You are given a string (of at most 100 characters) consisting of +lowercase characters, terminated with a # symbol. The string is the +"encrypted" form of an original string as follows - each character in +the original string has been shifted by a fixed integer n (where 1<= n +<= 25). + +Assuming that a is the 0th character in the alphabet, ..., and z is +the 25th character of the alphabet, in the encrypted version, we have: + +a becomes the nth character in the alphabet +b becomes the (n+1)%26th character in the alphabet, +... + +and so on. + +n is not known to you. You only know that the first character +represents 't'. From this information, you have to output the +original string. +*/ +#include + +int main() +{ + int i,c,d; + + d = getchar()-'t'; + putchar('t'); + + for(i=1;i<100;i++){ + c=getchar(); + if(c == '#'){ + break; + } + putchar('a'+((c-'a'-d)%26)); + } + + return 0; +} From 9bb6148e7bedcdd996813d095165151d32e8859d Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:32:43 +0530 Subject: [PATCH 028/110] Create SumofSeries.c --- Akash Kumar/SumofSeries.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Akash Kumar/SumofSeries.c diff --git a/Akash Kumar/SumofSeries.c b/Akash Kumar/SumofSeries.c new file mode 100644 index 000000000..5473f55f3 --- /dev/null +++ b/Akash Kumar/SumofSeries.c @@ -0,0 +1,24 @@ +/* Write a program to find Sum of series S=1+(1+2)+(1+2+3)+..….+(1+2+3+…+n) */ + +#include +int main() +{ + int n; + scanf("%d",&n); //Value of n is accepted from test case + + +// Use the printf statement as: +//printf("The Sum of Series up to Value %d = %d\n",n,sum); +int sum,sum1=0,i,j; +for(i=1;i<=n;i++) + { + sum=0; + for(j=1;j<=i;j++) + sum=sum+j; + sum1=sum1+sum; + } + + printf("The Sum of Series up to Value %d = %d\n",n,sum1); + + return 0; +} From b9fb11f2da03ed9c10814a259db3871da6c8428f Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:34:06 +0530 Subject: [PATCH 029/110] Create Trianglebystar.c --- Akash Kumar/Trianglebystar.c | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Akash Kumar/Trianglebystar.c diff --git a/Akash Kumar/Trianglebystar.c b/Akash Kumar/Trianglebystar.c new file mode 100644 index 000000000..f7b6a7e6c --- /dev/null +++ b/Akash Kumar/Trianglebystar.c @@ -0,0 +1,45 @@ +/* Write a program to print the below triangle pattern using asterisks (*), according to the value of N (Where N is the number of * in the middle row) +For example for N = 5 +The output will be + + * + ** + *** + **** +***** + **** + *** + ** + * +Please note that the middle row asterisks (*) starts from the first column, do not use any blank space between the asterisks (*), use /n to go to the next row. */ + +#include +int main() +{ +int N; //Number of * in the middle row +scanf("%d", &N); //Value of N is taken from test data + +int i,j,k,s=1; + for (i=1; i<=N; i++) { + for (k=s; k=1; i--) { + for (k=s; k>0; k--) { + printf(" "); + } + for (j=i; j>=1; j--) { + printf("*"); + } + s = s + 1; + printf("\n"); + } + +} From 3b60eaff2fa8d534248bdf85c47e707dd0f51b49 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:35:53 +0530 Subject: [PATCH 030/110] Create SumofdiagonalelementofMatrix.c --- Akash Kumar/SumofdiagonalelementofMatrix.c | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Akash Kumar/SumofdiagonalelementofMatrix.c diff --git a/Akash Kumar/SumofdiagonalelementofMatrix.c b/Akash Kumar/SumofdiagonalelementofMatrix.c new file mode 100644 index 000000000..8e5a54b39 --- /dev/null +++ b/Akash Kumar/SumofdiagonalelementofMatrix.c @@ -0,0 +1,29 @@ +#include + +int main() +{ + int a[10][10], n; + scanf("%d", &n); //Size of the matrix is taken from test data + +//Use the printf statement as: +//printf("Sum of the diagonal elements is = %d",variable_name); + int d1sum=0, d2sum=0, i, j; + for(i=0;i Date: Tue, 4 May 2021 21:45:38 +0530 Subject: [PATCH 031/110] Create Noof1inBinaryofanInt.cpp --- Akash Kumar/Noof1inBinaryofanInt.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Akash Kumar/Noof1inBinaryofanInt.cpp diff --git a/Akash Kumar/Noof1inBinaryofanInt.cpp b/Akash Kumar/Noof1inBinaryofanInt.cpp new file mode 100644 index 000000000..f6e3c4c63 --- /dev/null +++ b/Akash Kumar/Noof1inBinaryofanInt.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; +#define repeat(x) for(int _iterator_i = 0; _iterator_i < x; _iterator_i++) +#include +int main() { +int n; +cin >> n; +int cnt_of_ones = 0; +while (n != 0) { +if (n % 2 == 1) { +cnt_of_ones++; +} +n = n / 2; +} +cout << cnt_of_ones << endl; +} From afe122aae9da0a6a8ee04ef7d4fc5edf6a4b82a8 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:48:53 +0530 Subject: [PATCH 032/110] Create TransposeofMatrix.c --- Akash Kumar/TransposeofMatrix.c | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Akash Kumar/TransposeofMatrix.c diff --git a/Akash Kumar/TransposeofMatrix.c b/Akash Kumar/TransposeofMatrix.c new file mode 100644 index 000000000..db5e22376 --- /dev/null +++ b/Akash Kumar/TransposeofMatrix.c @@ -0,0 +1,36 @@ +#include + +void main() +{ + static int array[10][10]; + int i, j, m, n; + + printf("Enter the order of the matrix \n"); + scanf("%d %d", &m, &n); + printf("Enter the coefiicients of the matrix\n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + { + scanf("%d", &array[i][j]); + } + } + printf("The given matrix is \n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + { + printf(" %d", array[i][j]); + } + printf("\n"); + } + printf("Transpose of matrix is \n"); + for (j = 0; j < n; ++j) + { + for (i = 0; i < m; ++i) + { + printf(" %d", array[i][j]); + } + printf("\n"); + } +} From 74a2cd125dcdc5652fa447ae1f9077a1a2590d16 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:49:59 +0530 Subject: [PATCH 033/110] Create productofMatrix.c --- Akash Kumar/productofMatrix.c | 83 +++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Akash Kumar/productofMatrix.c diff --git a/Akash Kumar/productofMatrix.c b/Akash Kumar/productofMatrix.c new file mode 100644 index 000000000..033aa24cb --- /dev/null +++ b/Akash Kumar/productofMatrix.c @@ -0,0 +1,83 @@ +#include + #define MAXROWS 10 + #define MAXCOLS 10 + + void readMatrix(int arr[][MAXCOLS], int m, int n); + void printMatrix(int arr[][MAXCOLS], int m, int n); + void productMatrix(int array1[][MAXCOLS], int array2[][MAXCOLS], + int array3[][MAXCOLS], int m, int n); + + void main() + { + + int array1[MAXROWS][MAXCOLS], array2[MAXROWS][MAXCOLS], + array3[MAXROWS][MAXCOLS]; + int m, n; + + printf("Enter the value of m and n \n"); + scanf("%d %d", &m, &n); + + printf("Enter Matrix array1 \n"); + readMatrix(array1, m, n); + printf("Matrix array1 \n"); + printMatrix(array1, m, n); + + printf("Enter Matrix array2 \n"); + readMatrix(array2, m, n); + printf("Matrix B \n"); + printMatrix(array2, m, n); + + productMatrix(array1, array2, array3, m, n); + printf("The product matrix is \n"); + printMatrix(array3, m, n); + + } + + /* Input Matrix array1 */ + + void readMatrix(int arr[][MAXCOLS], int m, int n) + { + + int i, j; + for (i = 0; i < m; i++) + { + for (j = 0; j < n; j++) + { + scanf("%d", &arr[i][j]); + } + } + } + + void printMatrix(int arr[][MAXCOLS], int m, int n) + { + + int i, j; + for (i = 0; i < m; i++) + { + for (j = 0; j < n; j++) + { + printf("%3d", arr[i][j]); + } + printf("\n"); + } + } + + /* Multiplication of matrices */ + + void productMatrix(int array1[][MAXCOLS], int array2[][MAXCOLS], + int array3[][MAXCOLS], int m, int n) + { + + int i, j, k; + for (i = 0; i < m; i++) + { + for (j = 0; j < n; j++) + { + array3[i][j] = 0; + for (k = 0; k < n; k++) + { + array3[i][j] = array3[i][j] + array1[i][k] * array2[k][j]; + } + } + } + } From 121ded50addeced1c6e4bbce36882f22a8cf7981 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:51:05 +0530 Subject: [PATCH 034/110] Create MultiplicationofMatrixbyRecursion.c --- .../MultiplicationofMatrixbyRecursion.c | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Akash Kumar/MultiplicationofMatrixbyRecursion.c diff --git a/Akash Kumar/MultiplicationofMatrixbyRecursion.c b/Akash Kumar/MultiplicationofMatrixbyRecursion.c new file mode 100644 index 000000000..202439d0b --- /dev/null +++ b/Akash Kumar/MultiplicationofMatrixbyRecursion.c @@ -0,0 +1,79 @@ +#include + +void multiply(int, int, int [][10], int, int, int [][10], int [][10]); +void display(int, int, int[][10]); + +int main() +{ + int a[10][10], b[10][10], c[10][10] = {0}; + int m1, n1, m2, n2, i, j, k; + + printf("Enter rows and columns for Matrix A respectively: "); + scanf("%d%d", &m1, &n1); + printf("Enter rows and columns for Matrix B respectively: "); + scanf("%d%d", &m2, &n2); + if (n1 != m2) + { + printf("Matrix multiplication not possible.\n"); + } + else + { + printf("Enter elements in Matrix A:\n"); + for (i = 0; i < m1; i++) + for (j = 0; j < n1; j++) + { + scanf("%d", &a[i][j]); + } + printf("\nEnter elements in Matrix B:\n"); + for (i = 0; i < m2; i++) + for (j = 0; j < n2; j++) + { + scanf("%d", &b[i][j]); + } + multiply(m1, n1, a, m2, n2, b, c); + } + printf("On matrix multiplication of A and B the result is:\n"); + display(m1, n2, c); +} + +void multiply (int m1, int n1, int a[10][10], int m2, int n2, int b[10][10], int c[10][10]) +{ + static int i = 0, j = 0, k = 0; + + if (i >= m1) + { + return; + } + else if (i < m1) + { + if (j < n2) + { + if (k < n1) + { + c[i][j] += a[i][k] * b[k][j]; + k++; + multiply(m1, n1, a, m2, n2, b, c); + } + k = 0; + j++; + multiply(m1, n1, a, m2, n2, b, c); + } + j = 0; + i++; + multiply(m1, n1, a, m2, n2, b, c); + } +} + +void display(int m1, int n2, int c[10][10]) +{ + int i, j; + + for (i = 0; i < m1; i++) + { + for (j = 0; j < n2; j++) + { + printf("%d ", c[i][j]); + } + printf("\n"); + } +} From a0b4d0d13932d388b2fb58f536383075697cf81b Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:52:18 +0530 Subject: [PATCH 035/110] Create sumanddifferenceofMatrix.c --- Akash Kumar/sumanddifferenceofMatrix.c | 162 +++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 Akash Kumar/sumanddifferenceofMatrix.c diff --git a/Akash Kumar/sumanddifferenceofMatrix.c b/Akash Kumar/sumanddifferenceofMatrix.c new file mode 100644 index 000000000..752237660 --- /dev/null +++ b/Akash Kumar/sumanddifferenceofMatrix.c @@ -0,0 +1,162 @@ +#include + #include + + void readmatA(); + void printmatA(); + void readmatB(); + void printmatB(); + + void sum(); + void diff(); + + int a[10][10], b[10][10], sumarray[10][10], arraydiff[10][10]; + int i, j, row1, column1, row2, column2; + + void main() + { + + printf("Enter the order of the matrix A \n"); + scanf("%d %d", &row1, &column1); + + printf("Enter the order of the matrix B \n"); + scanf("%d %d", &row2, &column2); + + if (row1 != row2 && column1 != column2) + { + printf("Addition and subtraction are possible \n"); + exit(1); + } + + else + { + + printf("Enter the elements of matrix A \n"); + readmatA(); + + printf("MATRIX A is \n"); + printmatA(); + + printf("Enter the elements of matrix B \n"); + readmatB(); + + printf("MATRIX B is \n"); + printmatB(); + + sum(); + diff(); + + } + + } + + /* Function to read a matrix A */ + + void readmatA() + { + for (i = 0; i < row1; i++) + { + for (j = 0; j < column1; j++) + { + scanf("%d", &a[i][j]); + } + } + return; + } + + /* Function to read a matrix B */ + + void readmatB() + { + for (i = 0; i < row2; i++) + { + for (j = 0; j < column2; j++) + { + scanf("%d", &b[i][j]); + } + } + } + + /* Function to print a matrix A */ + + void printmatA() + { + for (i = 0; i < row1; i++) + { + for (j = 0; j < column1; j++) + { + printf("%3d", a[i][j]); + } + printf("\n"); + } + + } + + /* Function to print a matrix B */ + + void printmatB() + { + for (i = 0; i < row2; i++) + { + for (j = 0; j < column2; j++) + { + printf("%3d", b[i][j]); + } + printf("\n"); + } + + } + + /* Function to do the sum of elements of matrix A and Matrix B */ + + void sum() + { + for (i = 0; i < row1; i++) + { + for (j = 0; j < column2; j++) + { + sumarray[i][j] = a[i][j] + b[i][j]; + } + + } + + printf("Sum matrix is \n"); + for (i = 0; i < row1; i++) + { + for (j = 0; j < column2; j++) + { + printf("%3d", sumarray[i][j]) ; + } + printf("\n"); + + } + return; + + } + + /* Function to do the difference of elements of matrix A and Matrix B */ + + void diff() + { + for (i = 0; i < row1; i++) + { + for (j = 0; j < column2; j++) + { + arraydiff[i][j] = a[i][j] - b[i][j]; + } + + } + + printf("Difference matrix is \n"); + for (i = 0; i < row1; i++) + { + for (j = 0; j < column2; j++) + { + printf("%3d", arraydiff[i][j]); + + } + printf("\n"); + + } + return; + + } From 0b1d6a433c3645440273f7d1f05950b3b7c251f0 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:53:16 +0530 Subject: [PATCH 036/110] Create MatrixEqualornot.c --- Akash Kumar/MatrixEqualornot.c | 85 ++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Akash Kumar/MatrixEqualornot.c diff --git a/Akash Kumar/MatrixEqualornot.c b/Akash Kumar/MatrixEqualornot.c new file mode 100644 index 000000000..e14e9b4b6 --- /dev/null +++ b/Akash Kumar/MatrixEqualornot.c @@ -0,0 +1,85 @@ +#include + #include + + void main() + { + + int a[10][10], b[10][10]; + int i, j, row1, column1, row2, column2, flag = 1; + + printf("Enter the order of the matrix A \n"); + scanf("%d %d", &row1, &column1); + + printf("Enter the order of the matrix B \n"); + scanf("%d %d", &row2, &column2); + + printf("Enter the elements of matrix A \n"); + for (i = 0; i < row1; i++) + { + for (j = 0; j < column1; j++) + { + scanf("%d", &a[i][j]); + } + } + + printf("Enter the elements of matrix B \n"); + for (i = 0; i < row2; i++) + { + for (j = 0; j < column2; j++) + { + scanf("%d", &b[i][j]); + } + } + + printf("MATRIX A is \n"); + for (i = 0; i < row1; i++) + { + for (j = 0; j < column1; j++) + { + printf("%3d", a[i][j]); + } + printf("\n"); + + } + + printf("MATRIX B is \n"); + for (i = 0; i < row2; i++) + { + for (j = 0; j < column2; j++) + { + printf("%3d", b[i][j]); + } + printf("\n"); + + } + + /* Comparing two matrices for equality */ + + if (row1 == row2 && column1 == column2) + { + printf("Matrices can be compared \n"); + for (i = 0; i < row1; i++) + { + for (j = 0; j < column2; j++) + { + if (a[i][j] != b[i][j]) + { + flag = 0; + break; + } + } + } + } + + else + { + printf(" Cannot be compared\n"); + exit(1); + } + + if (flag == 1) + printf("Two matrices are equal \n"); + else + printf("But, two matrices are not equal \n"); + + } From 2d91837aa59843f1ccb953516ecdf2e9954217b8 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:54:09 +0530 Subject: [PATCH 037/110] Create IdentityMatrixornot.c --- Akash Kumar/IdentityMatrixornot.c | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Akash Kumar/IdentityMatrixornot.c diff --git a/Akash Kumar/IdentityMatrixornot.c b/Akash Kumar/IdentityMatrixornot.c new file mode 100644 index 000000000..a02c13770 --- /dev/null +++ b/Akash Kumar/IdentityMatrixornot.c @@ -0,0 +1,51 @@ +#include + +int main (void) +{ + int a[10][10]; + int i = 0, j = 0, row = 0, col = 0; + + printf ("Enter the order of the matrix (mxn):\n"); + printf ("where m = number of rows; and\n"); + printf (" n = number of columns\n"); + scanf ("%d %d", &row, &col); + + int flag = 0; + + printf ("Enter the elements of the matrix\n"); + for (i = 0; i < row; i++) + { + for (j = 0; j < col; j++) + { + scanf ("%d", &a[i][j]); + } + } + + for (i = 0; i < row; i++) + { + for (j = 0; j < col; j++) + { + if (i == j && a[i][j] != 1) + { + flag = -1; + break; + } + else if (i != j && a[i][j] != 0) + { + flag = -1; + break; + } + } + } + + if (flag == 0) + { + printf ("It is a IDENTITY MATRIX\n"); + } + else + { + printf ("It is NOT an identity matrix\n"); + } + + return 0; +} From fdb0baeb6cdd95156a6bc6c5197f6ce02305b795 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:55:07 +0530 Subject: [PATCH 038/110] Create SparseMatrixornot.c --- Akash Kumar/SparseMatrixornot.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Akash Kumar/SparseMatrixornot.c diff --git a/Akash Kumar/SparseMatrixornot.c b/Akash Kumar/SparseMatrixornot.c new file mode 100644 index 000000000..a4183b151 --- /dev/null +++ b/Akash Kumar/SparseMatrixornot.c @@ -0,0 +1,30 @@ +#include + +void main () +{ + static int array[10][10]; + int i, j, m, n; + int counter = 0; + + printf("Enter the order of the matix \n"); + scanf("%d %d", &m, &n); + printf("Enter the co-efficients of the matix \n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + { + scanf("%d", &array[i][j]); + if (array[i][j] == 0) + { + ++counter; + } + } + } + if (counter > ((m * n) / 2)) + { + printf("The given matrix is sparse matrix \n"); + } + else + printf("The given matrix is not a sparse matrix \n"); + printf("There are %d number of zeros", counter); +} From 953d7fc1976c3a6ae38eca3cbce8223aa0fbde6f Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:56:18 +0530 Subject: [PATCH 039/110] Create InterchangeRowandColumn.c --- Akash Kumar/InterchangeRowandColumn.c | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Akash Kumar/InterchangeRowandColumn.c diff --git a/Akash Kumar/InterchangeRowandColumn.c b/Akash Kumar/InterchangeRowandColumn.c new file mode 100644 index 000000000..66a4523ff --- /dev/null +++ b/Akash Kumar/InterchangeRowandColumn.c @@ -0,0 +1,60 @@ +#include + +void main() +{ + static int array1[10][10], array2[10][10]; + int i, j, m, n, a, b, c, p, q, r; + + printf("Enter the order of the matrix \n"); + scanf("%d %d", &m, &n); + printf("Enter the co-efficents of the matrix \n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + { + scanf("%d,", &array1[i][j]); + array2[i][j] = array1[i][j]; + } + } + printf("Enter the numbers of two rows to be exchanged \n"); + scanf("%d %d", &a, &b); + for (i = 0; i < m; ++i) + { + /* first row has index is 0 */ + c = array1[a - 1][i]; + array1[a - 1][i] = array1[b - 1][i]; + array1[b - 1][i] = c; + } + printf("Enter the numbers of two columns to be exchanged \n"); + scanf("%d %d", &p, &q); + printf("The given matrix is \n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + printf(" %d", array2[i][j]); + printf("\n"); + } + for (i = 0; i < n; ++i) + { + /* first column index is 0 */ + r = array2[i][p - 1]; + array2[i][p - 1] = array2[i][q - 1]; + array2[i][q - 1] = r; + } + printf("The matix after interchanging the two rows(in the original matrix) \n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + { + printf(" %d", array1[i][j]); + } + printf("\n"); + } + printf("The matix after interchanging the two columns(in the original matrix) \n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + printf(" %d", array2[i][j]); + printf("\n"); + } +} From 2fd2db33a2ff9f7445697d71474323f1e06228c6 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:57:44 +0530 Subject: [PATCH 040/110] Create NoOfOddEveninMatrix.c --- Akash Kumar/NoOfOddEveninMatrix.c | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Akash Kumar/NoOfOddEveninMatrix.c diff --git a/Akash Kumar/NoOfOddEveninMatrix.c b/Akash Kumar/NoOfOddEveninMatrix.c new file mode 100644 index 000000000..93fed1980 --- /dev/null +++ b/Akash Kumar/NoOfOddEveninMatrix.c @@ -0,0 +1,39 @@ +#include + void main() + { + + static int array[10][10]; + int i, j, m, n, even = 0, odd = 0; + + printf("Enter the order ofthe matrix \n"); + scanf("%d %d", &m, &n); + + printf("Enter the coefficients of matrix \n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + { + scanf("%d", &array[i][j]); + if ((array[i][j] % 2) == 0) + { + ++even; + } + else + ++odd; + } + + } + + printf("The given matrix is \n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + { + printf(" %d", array[i][j]); + } + printf("\n"); + } + + printf("\n The frequency of occurrence of odd number = %d \n", odd); + printf("The frequency of occurrence of even number = %d\n", even); + From b879e69af3825e2ff07ae8d855ff91e7a189add2 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 21:59:04 +0530 Subject: [PATCH 041/110] Create InterchangeofDiagonal.c --- Akash Kumar/InterchangeofDiagonal.c | 59 +++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Akash Kumar/InterchangeofDiagonal.c diff --git a/Akash Kumar/InterchangeofDiagonal.c b/Akash Kumar/InterchangeofDiagonal.c new file mode 100644 index 000000000..ca4da13d6 --- /dev/null +++ b/Akash Kumar/InterchangeofDiagonal.c @@ -0,0 +1,59 @@ + + #include + void main () + { + + static int array[10][10]; + int i, j, m, n, a; + + printf("Enter the order of the matix \n"); + scanf("%d %d", &m, &n); + + if (m == n) + { + printf("Enter the co-efficients of the matrix\n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + { + scanf("%dx%d", &array[i][j]); + } + } + + printf("The given matrix is \n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + { + printf(" %d", array[i][j]); + } + printf("\n"); + } + + for (i = 0; i < m; ++i) + { + a = array[i][i]; + array[i][i] = array[i][m - i - 1]; + array[i][m - i - 1] = a; + } + + printf("The matrix after changing the \n"); + printf("main diagonal & secondary diagonal\n"); + for (i = 0; i < m; ++i) + { + for (j = 0; j < n; ++j) + { + printf(" %d", array[i][j]); + + } + + printf("\n"); + + } + + } + + else + printf("The given order is not square matrix\n"); + + } From 578b0b87c4091edae626d8583f33dbb50e78e464 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:05:14 +0530 Subject: [PATCH 042/110] Create LCMbyRecursion.c --- Akash Kumar/LCMbyRecursion.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Akash Kumar/LCMbyRecursion.c diff --git a/Akash Kumar/LCMbyRecursion.c b/Akash Kumar/LCMbyRecursion.c new file mode 100644 index 000000000..45d9464c4 --- /dev/null +++ b/Akash Kumar/LCMbyRecursion.c @@ -0,0 +1,28 @@ +#include + +int lcm(int, int); + +int main() +{ + int a, b, result; + int prime[100]; + + printf("Enter two numbers: "); + scanf("%d%d", &a, &b); + result = lcm(a, b); + printf("The LCM of %d and %d is %d\n", a, b, result); + return 0; +} + +int lcm(int a, int b) +{ + static int common = 1; + + if (common % a == 0 && common % b == 0) + { + return common; + } + common++; + lcm(a, b); + return common; +} From 85fe72727b7a4eb16c3bd522c3546f4129ed7c1b Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:06:11 +0530 Subject: [PATCH 043/110] Create GCDbyRecursion.c --- Akash Kumar/GCDbyRecursion.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Akash Kumar/GCDbyRecursion.c diff --git a/Akash Kumar/GCDbyRecursion.c b/Akash Kumar/GCDbyRecursion.c new file mode 100644 index 000000000..44437e26b --- /dev/null +++ b/Akash Kumar/GCDbyRecursion.c @@ -0,0 +1,29 @@ +#include + +int gcd(int, int); + +int main() +{ + int a, b, result; + + printf("Enter the two numbers to find their GCD: "); + scanf("%d%d", &a, &b); + result = gcd(a, b); + printf("The GCD of %d and %d is %d.\n", a, b, result); +} + +int gcd(int a, int b) +{ + while (a != b) + { + if (a > b) + { + return gcd(a - b, b); + } + else + { + return gcd(a, b - a); + } + } + return a; +} From 1f5525a245611257f544b8c3a7a5f9ba90a01d60 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:07:12 +0530 Subject: [PATCH 044/110] Create productbyRecursion.c --- Akash Kumar/productbyRecursion.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Akash Kumar/productbyRecursion.c diff --git a/Akash Kumar/productbyRecursion.c b/Akash Kumar/productbyRecursion.c new file mode 100644 index 000000000..ed0d12c79 --- /dev/null +++ b/Akash Kumar/productbyRecursion.c @@ -0,0 +1,30 @@ +#include + +int product(int, int); + +int main() +{ + int a, b, result; + + printf("Enter two numbers to find their product: "); + scanf("%d%d", &a, &b); + result = product(a, b); + printf("Product of %d and %d is %d\n", a, b, result); + return 0; +} + +int product(int a, int b) +{ + if (a < b) + { + return product(b, a); + } + else if (b != 0) + { + return (a + product(a, b - 1)); + } + else + { + return 0; + } +} From ca59f5e7b505c54ed0c9b93e3f70ba14bb38cd9d Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:07:54 +0530 Subject: [PATCH 045/110] Create Powerbyrecursion.c --- Akash Kumar/Powerbyrecursion.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Akash Kumar/Powerbyrecursion.c diff --git a/Akash Kumar/Powerbyrecursion.c b/Akash Kumar/Powerbyrecursion.c new file mode 100644 index 000000000..7ebd6efb7 --- /dev/null +++ b/Akash Kumar/Powerbyrecursion.c @@ -0,0 +1,26 @@ +#include + +long power (int, int); + +int main() +{ + int pow, num; + long result; + + printf("Enter a number: "); + scanf("%d", &num); + printf("Enter it's power: "); + scanf("%d", &pow); + result = power(num, pow); + printf("%d^%d is %ld", num, pow, result); + return 0; +} + +long power (int num, int pow) +{ + if (pow) + { + return (num * power(num, pow - 1)); + } + return 1; +} From c05ed59ed5288fdb41acc62052b86d25e8cdde47 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:08:55 +0530 Subject: [PATCH 046/110] Create BinarybyRecursion.c --- Akash Kumar/BinarybyRecursion.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Akash Kumar/BinarybyRecursion.c diff --git a/Akash Kumar/BinarybyRecursion.c b/Akash Kumar/BinarybyRecursion.c new file mode 100644 index 000000000..ad77691cd --- /dev/null +++ b/Akash Kumar/BinarybyRecursion.c @@ -0,0 +1,25 @@ +#include + +int binary_conversion(int); + +int main() +{ + int num, bin; + + printf("Enter a decimal number: "); + scanf("%d", &num); + bin = binary_conversion(num); + printf("The binary equivalent of %d is %d\n", num, bin); +} + +int binary_conversion(int num) +{ + if (num == 0) + { + return 0; + } + else + { + return (num % 2) + 10 * binary_conversion(num / 2); + } +} From 7f24a8990b447b4d8814d19f8e718c430fcdb0cd Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:12:31 +0530 Subject: [PATCH 047/110] Create firstCap.c --- Akash Kumar/firstCap.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Akash Kumar/firstCap.c diff --git a/Akash Kumar/firstCap.c b/Akash Kumar/firstCap.c new file mode 100644 index 000000000..21c36decc --- /dev/null +++ b/Akash Kumar/firstCap.c @@ -0,0 +1,39 @@ +#include +#include +#include + +char caps_check(char *); + +int main() +{ + char string[20], letter; + + printf("Enter a string to find it's first capital letter: "); + scanf("%s", string); + letter = caps_check(string); + if (letter == 0) + { + printf("No capital letter is present in %s.\n", string); + } + else + { + printf("The first capital letter in %s is %c.\n", string, letter); } + return 0; + } + char caps_check(char *string) + { + static int i = 0; + if (i < strlen(string)) + { + if (isupper(string[i])) + { + return string[i]; + } + else + { + i = i + 1; + return caps_check(string); + } + } + else return 0; + } From fd7088ec3ef5dca103b3b5099120573dabafdfea Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:13:51 +0530 Subject: [PATCH 048/110] Create BintoHexa.c --- Akash Kumar/BintoHexa.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Akash Kumar/BintoHexa.c diff --git a/Akash Kumar/BintoHexa.c b/Akash Kumar/BintoHexa.c new file mode 100644 index 000000000..169b6a659 --- /dev/null +++ b/Akash Kumar/BintoHexa.c @@ -0,0 +1,18 @@ +#include + +int main() +{ + long int binary, hexadecimalval = 0, i = 1, remainder; + + printf("Enter the binary number: "); + scanf("%ld", &binary); + while (binaryval != 0) + { + remainder = binary % 10; + hexadecimalval = hexadecimalval + remainder * i; + i = i * 2; + binary = binary / 10; + } + printf("Equivalent hexadecimal value: %lX", hexadecimalval); + return 0; +} From b9b64b945d5f96ed9cae650e690efbeae3cac46c Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:14:39 +0530 Subject: [PATCH 049/110] Create BinarytoOctal.c --- Akash Kumar/BinarytoOctal.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Akash Kumar/BinarytoOctal.c diff --git a/Akash Kumar/BinarytoOctal.c b/Akash Kumar/BinarytoOctal.c new file mode 100644 index 000000000..2caa85306 --- /dev/null +++ b/Akash Kumar/BinarytoOctal.c @@ -0,0 +1,18 @@ +#include + +int main() +{ + long int binarynum, octalnum = 0, j = 1, remainder; + + printf("Enter the value for binary number: "); + scanf("%ld", &binarynum); + while (binarynum != 0) + { + remainder = binarynum % 10; + octalnum = octalnum + remainder * j; + j = j * 2; + binarynum = binarynum / 10; + } + printf("Equivalent octal value: %lo", octalnum); + return 0; +} From 7850da537c20d94c535feb0f959e058457874ed2 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:15:33 +0530 Subject: [PATCH 050/110] Create DectoOctal.c --- Akash Kumar/DectoOctal.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Akash Kumar/DectoOctal.c diff --git a/Akash Kumar/DectoOctal.c b/Akash Kumar/DectoOctal.c new file mode 100644 index 000000000..cd221ee6a --- /dev/null +++ b/Akash Kumar/DectoOctal.c @@ -0,0 +1,20 @@ +#include + +int main() +{ + long decimalnum, remainder, quotient; + int octalNumber[100], i = 1, j; + + printf("Enter the decimal number: "); + scanf("%ld", &decimalnum); + quotient = decimalnum; + while (quotient != 0) + { + octalNumber[i++] = quotient % 8; + quotient = quotient / 8; + } + printf("Equivalent octal value of decimal no %d: ", decimalnum); + for (j = i - 1; j > 0; j--) + printf("%d", octalNumber[j]); + return 0; +} From c2fc4a332f8d6407478f62cec82ae2892f0c2044 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:16:25 +0530 Subject: [PATCH 051/110] Create DecimaltoHexa.c --- Akash Kumar/DecimaltoHexa.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Akash Kumar/DecimaltoHexa.c diff --git a/Akash Kumar/DecimaltoHexa.c b/Akash Kumar/DecimaltoHexa.c new file mode 100644 index 000000000..12666d629 --- /dev/null +++ b/Akash Kumar/DecimaltoHexa.c @@ -0,0 +1,26 @@ +#include + +int main() +{ + long decimalnum, quotient, remainder; + int i, j = 0; + char hexadecimalnum[100]; + + printf("Enter decimal number: "); + scanf("%ld", &decimalnum); + + quotient = decimalnum; + + while (quotient != 0) + { + remainder = quotient % 16; + if (remainder < 10) + hexadecimalnum[j++] = 48 + remainder; + else + hexadecimalnum[j++] = 55 + remainder; + quotient = quotient / 16; + } + for (i = j; i >= 0; i--) + printf("%c", hexadecimalnum[i]); + return 0; +} From 3a4bf2b1d33eb7d00c8f7572d29f327d27a5a815 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:17:21 +0530 Subject: [PATCH 052/110] Create RomanTodec.c --- Akash Kumar/RomanTodec.c | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Akash Kumar/RomanTodec.c diff --git a/Akash Kumar/RomanTodec.c b/Akash Kumar/RomanTodec.c new file mode 100644 index 000000000..edde6caee --- /dev/null +++ b/Akash Kumar/RomanTodec.c @@ -0,0 +1,61 @@ +#include +#include + +int digit(char); + +int main(){ + + char roman_Number[1000]; + int i=0; + long int number =0; + + printf("Enter any roman number (Valid digits are I, V, X, L, C, D, M): \n"); + scanf("%s",roman_Number); + + while(roman_Number[i]){ + + if(digit(roman_Number[i]) < 0){ + printf("Invalid roman digit : %c",roman_Number[i]); + return 0; + } + + if((strlen(roman_Number) -i) > 2){ + if(digit(roman_Number[i]) < digit(roman_Number[i+2])){ + printf("Invalid roman number"); + return 0; + } + } + + if(digit(roman_Number[i]) >= digit(roman_Number[i+1])) + number = number + digit(roman_Number[i]); + else{ + number = number + (digit(roman_Number[i+1]) - digit(roman_Number[i])); + i++; + } + i++; + } + + printf("Its decimal value is : %ld",number); + + return 0; + +} + +int digit(char c){ + + int value=0; + + switch(c){ + case 'I': value = 1; break; + case 'V': value = 5; break; + case 'X': value = 10; break; + case 'L': value = 50; break; + case 'C': value = 100; break; + case 'D': value = 500; break; + case 'M': value = 1000; break; + case '\0': value = 0; break; + default: value = -1; + } + + return value; +} From 3ce5c668895fe5c7dfc7b9a064ee38283357c103 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:18:37 +0530 Subject: [PATCH 053/110] Create OctaltoDec.c --- Akash Kumar/OctaltoDec.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Akash Kumar/OctaltoDec.c diff --git a/Akash Kumar/OctaltoDec.c b/Akash Kumar/OctaltoDec.c new file mode 100644 index 000000000..c78992685 --- /dev/null +++ b/Akash Kumar/OctaltoDec.c @@ -0,0 +1,39 @@ +#include +#define MAX 1000 + +int main() +{ + char octalnum[MAX]; + long i = 0; + + printf("Enter any octal number: "); + scanf("%s", octalnum); + printf("Equivalent binary value: "); + while (octalnum[i]) + { + switch (octalnum[i]) + { + case '0': + printf("000"); break; + case '1': + printf("001"); break; + case '2': + printf("010"); break; + case '3': + printf("011"); break; + case '4': + printf("100"); break; + case '5': + printf("101"); break; + case '6': + printf("110"); break; + case '7': + printf("111"); break; + default: + printf("\n Invalid octal digit %c ", octalnum[i]); + return 0; + } + i++; + } + return 0; +} From 65b6d391655b3fe49179fbea66023ff088e5dbdd Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:19:30 +0530 Subject: [PATCH 054/110] Create HexatoDec.c --- Akash Kumar/HexatoDec.c | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Akash Kumar/HexatoDec.c diff --git a/Akash Kumar/HexatoDec.c b/Akash Kumar/HexatoDec.c new file mode 100644 index 000000000..a8c8a7680 --- /dev/null +++ b/Akash Kumar/HexatoDec.c @@ -0,0 +1,67 @@ +#include +#define MAX 1000 + +int main() +{ + char binarynum[MAX], hexa[MAX]; + long int i = 0; + + printf("Enter the value for hexadecimal "); + scanf("%s", hexa); + printf("\n Equivalent binary value: "); + while (hexa[i]) + { + switch (hexa[i]) + { + case '0': + printf("0000"); break; + case '1': + printf("0001"); break; + case '2': + printf("0010"); break; + case '3': + printf("0011"); break; + case '4': + printf("0100"); break; + case '5': + printf("0101"); break; + case '6': + printf("0110"); break; + case '7': + printf("0111"); break; + case '8': + printf("1000"); break; + case '9': + printf("1001"); break; + case 'A': + printf("1010"); break; + case 'B': + printf("1011"); break; + case 'C': + printf("1100"); break; + case 'D': + printf("1101"); break; + case 'E': + printf("1110"); break; + case 'F': + printf("1111"); break; + case 'a': + printf("1010"); break; + case 'b': + printf("1011"); break; + case 'c': + printf("1100"); break; + case 'd': + printf("1101"); break; + case 'e': + printf("1110"); break; + case 'f': + printf("1111"); break; + default: + printf("\n Invalid hexa digit %c ", hexa[i]); + return 0; + } + i++; + } + return 0; +} From 708ba2bb947be43b2657625e1b3055cf4098e103 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:21:16 +0530 Subject: [PATCH 055/110] Create ShortestHextoDec.c --- Akash Kumar/ShortestHextoDec.c | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Akash Kumar/ShortestHextoDec.c diff --git a/Akash Kumar/ShortestHextoDec.c b/Akash Kumar/ShortestHextoDec.c new file mode 100644 index 000000000..b1dd6a5c0 --- /dev/null +++ b/Akash Kumar/ShortestHextoDec.c @@ -0,0 +1,8 @@ +#include +int main() +{ + int re; + scanf("%x",&re); + printf("%d",re); + return 0; +} From 41307281d80b0aae519435251d03c69c4d31a723 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:22:11 +0530 Subject: [PATCH 056/110] Create ShortestDectoHex.c --- Akash Kumar/ShortestDectoHex.c | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Akash Kumar/ShortestDectoHex.c diff --git a/Akash Kumar/ShortestDectoHex.c b/Akash Kumar/ShortestDectoHex.c new file mode 100644 index 000000000..b1dd6a5c0 --- /dev/null +++ b/Akash Kumar/ShortestDectoHex.c @@ -0,0 +1,8 @@ +#include +int main() +{ + int re; + scanf("%x",&re); + printf("%d",re); + return 0; +} From 2d009c6a7add5b6158a3387e704542cbf8e127ac Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:23:40 +0530 Subject: [PATCH 057/110] Create ShortestdectoOct.c --- Akash Kumar/ShortestdectoOct.c | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Akash Kumar/ShortestdectoOct.c diff --git a/Akash Kumar/ShortestdectoOct.c b/Akash Kumar/ShortestdectoOct.c new file mode 100644 index 000000000..eff8a2773 --- /dev/null +++ b/Akash Kumar/ShortestdectoOct.c @@ -0,0 +1,8 @@ +#include +int main() +{ + int re; + scanf("%d",&re); + printf("%o",re); + return 0; +} From 72192a5a4584150db851c02aa831c2ae60416270 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:24:21 +0530 Subject: [PATCH 058/110] Create ShortestOcttoDec.c --- Akash Kumar/ShortestOcttoDec.c | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Akash Kumar/ShortestOcttoDec.c diff --git a/Akash Kumar/ShortestOcttoDec.c b/Akash Kumar/ShortestOcttoDec.c new file mode 100644 index 000000000..9cdf48cde --- /dev/null +++ b/Akash Kumar/ShortestOcttoDec.c @@ -0,0 +1,8 @@ +#include +int main() +{ + int re; + scanf("%o",&re); + printf("%d",re); + return 0; +} From 3b29e41c0d2143f3d9e287d1f8cd2c9abc76c52c Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:25:19 +0530 Subject: [PATCH 059/110] Create NotoRom.c --- Akash Kumar/NotoRom.c | 123 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 Akash Kumar/NotoRom.c diff --git a/Akash Kumar/NotoRom.c b/Akash Kumar/NotoRom.c new file mode 100644 index 000000000..708ab3504 --- /dev/null +++ b/Akash Kumar/NotoRom.c @@ -0,0 +1,123 @@ +#include + +void predigit(char num1, char num2); +void postdigit(char c, int n); + +char romanval[1000]; +int i = 0; +int main() +{ + int j; + long number; + + printf("Enter the number: "); + scanf("%d", &number); + if (number <= 0) + { + printf("Invalid number"); + return 0; + } + while (number != 0) + { + if (number >= 1000) + { + postdigit('M', number / 1000); + number = number - (number / 1000) * 1000; + } + else if (number >= 500) + { + if (number < (500 + 4 * 100)) + { + postdigit('D', number / 500); + number = number - (number / 500) * 500; + } + else + { + predigit('C','M'); + number = number - (1000-100); + } + } + else if (number >= 100) + { + if (number < (100 + 3 * 100)) + { + postdigit('C', number / 100); + number = number - (number / 100) * 100; + } + else + { + predigit('L', 'D'); + number = number - (500 - 100); + } + } + else if (number >= 50 ) + { + if (number < (50 + 4 * 10)) + { + postdigit('L', number / 50); + number = number - (number / 50) * 50; + } + else + { + predigit('X','C'); + number = number - (100-10); + } + } + else if (number >= 10) + { + if (number < (10 + 3 * 10)) + { + postdigit('X', number / 10); + number = number - (number / 10) * 10; + } + else + { + predigit('X','L'); + number = number - (50 - 10); + } + } + else if (number >= 5) + { + if (number < (5 + 4 * 1)) + { + postdigit('V', number / 5); + number = number - (number / 5) * 5; + } + else + { + predigit('I', 'X'); + number = number - (10 - 1); + } + } + else if (number >= 1) + { + if (number < 4) + { + postdigit('I', number / 1); + number = number - (number / 1) * 1; + } + else + { + predigit('I', 'V'); + number = number - (5 - 1); + } + } + } + printf("Roman number is: "); + for(j = 0; j < i; j++) + printf("%c", romanval[j]); + return 0; +} + +void predigit(char num1, char num2) +{ + romanval[i++] = num1; + romanval[i++] = num2; +} + +void postdigit(char c, int n) +{ + int j; + for (j = 0; j < n; j++) + romanval[i++] = c; +} From b09346fac959cf2af342509494ccf29799c3e7ba Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:26:24 +0530 Subject: [PATCH 060/110] Create octaltoDecima;.c --- Akash Kumar/octaltoDecima;.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Akash Kumar/octaltoDecima;.c diff --git a/Akash Kumar/octaltoDecima;.c b/Akash Kumar/octaltoDecima;.c new file mode 100644 index 000000000..586fdc578 --- /dev/null +++ b/Akash Kumar/octaltoDecima;.c @@ -0,0 +1,19 @@ +#include +#include + +int main() +{ + + long int octal, decimal = 0; + int i = 0; + + printf("Enter any octal number: "); + scanf("%ld", &octal); + while (octal != 0) + { + decimal = decimal +(octal % 10)* pow(8, i++); + octal = octal / 10; + } + printf("Equivalent decimal value: %ld",decimal); + return 0; +} From 990e735508ba605c190f008fed1c7e02099a8219 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:27:06 +0530 Subject: [PATCH 061/110] Rename OctaltoDec.c to OctaltoBinary.c --- Akash Kumar/{OctaltoDec.c => OctaltoBinary.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Akash Kumar/{OctaltoDec.c => OctaltoBinary.c} (100%) diff --git a/Akash Kumar/OctaltoDec.c b/Akash Kumar/OctaltoBinary.c similarity index 100% rename from Akash Kumar/OctaltoDec.c rename to Akash Kumar/OctaltoBinary.c From f12da4f95ecf368848438dee7d061e05a8c708f3 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:28:21 +0530 Subject: [PATCH 062/110] Create SumofNbyrecursion.c --- Akash Kumar/SumofNbyrecursion.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Akash Kumar/SumofNbyrecursion.c diff --git a/Akash Kumar/SumofNbyrecursion.c b/Akash Kumar/SumofNbyrecursion.c new file mode 100644 index 000000000..868101546 --- /dev/null +++ b/Akash Kumar/SumofNbyrecursion.c @@ -0,0 +1,29 @@ +#include + +void display_sum(int); + +int main() +{ + int num; + + printf("Enter the Nth number: "); + scanf("%d", &num); + display_sum(num); + return 0; +} + +void display_sum(int num) +{ + static int sum = 0; + + if (num == 0) + { + printf("Sum of first N numbers is %d\n", sum); + return; + } + else + { + sum += num; + display_sum(--num); + } +} From b5defa52d5142fa5c5549b4dbac5d8cb6e8af09d Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:29:05 +0530 Subject: [PATCH 063/110] Create SumofDigitbyRexursion.c --- Akash Kumar/SumofDigitbyRexursion.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Akash Kumar/SumofDigitbyRexursion.c diff --git a/Akash Kumar/SumofDigitbyRexursion.c b/Akash Kumar/SumofDigitbyRexursion.c new file mode 100644 index 000000000..f1b2360dd --- /dev/null +++ b/Akash Kumar/SumofDigitbyRexursion.c @@ -0,0 +1,26 @@ +#include + +int sum (int a); + +int main() +{ + int num, result; + + printf("Enter the number: "); + scanf("%d", &num); + result = sum(num); + printf("Sum of digits in %d is %d\n", num, result); + return 0; +} + +int sum (int num) +{ + if (num != 0) + { + return (num % 10 + sum (num / 10)); + } + else + { + return 0; + } +} From e33641348fa20fdb48533e0f6c40a19852468b0d Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:37:27 +0530 Subject: [PATCH 064/110] Add files via upload --- Akash Kumar/Fib.c | 14 +++++++ Akash Kumar/Noof1.c | 61 +++++++++++++++++++++++++++ Akash Kumar/Occurancesubaaray.c | 42 +++++++++++++++++++ Akash Kumar/Question2.c | 39 +++++++++++++++++ Akash Kumar/a.c | 35 ++++++++++++++++ Akash Kumar/candy.c | 31 ++++++++++++++ Akash Kumar/ip.c | 34 +++++++++++++++ Akash Kumar/next.c | 16 +++++++ Akash Kumar/oddarray.c | 26 ++++++++++++ Akash Kumar/tempCodeRunnerFile.c | 11 +++++ Akash Kumar/triplet.c | 72 ++++++++++++++++++++++++++++++++ 11 files changed, 381 insertions(+) create mode 100644 Akash Kumar/Fib.c create mode 100644 Akash Kumar/Noof1.c create mode 100644 Akash Kumar/Occurancesubaaray.c create mode 100644 Akash Kumar/Question2.c create mode 100644 Akash Kumar/a.c create mode 100644 Akash Kumar/candy.c create mode 100644 Akash Kumar/ip.c create mode 100644 Akash Kumar/next.c create mode 100644 Akash Kumar/oddarray.c create mode 100644 Akash Kumar/tempCodeRunnerFile.c create mode 100644 Akash Kumar/triplet.c diff --git a/Akash Kumar/Fib.c b/Akash Kumar/Fib.c new file mode 100644 index 000000000..0d7baa91b --- /dev/null +++ b/Akash Kumar/Fib.c @@ -0,0 +1,14 @@ +#include +int main() { + int i, n=50, t1 = 0, t2 = 1, nextTerm; + printf("Fibonacci Series: "); + + for (i = 1; i <= n; ++i) { + printf("%d, ", t1); + nextTerm = t1 + t2; + t1 = t2; + t2 = nextTerm; + } + + return 0; +} \ No newline at end of file diff --git a/Akash Kumar/Noof1.c b/Akash Kumar/Noof1.c new file mode 100644 index 000000000..c789ea45b --- /dev/null +++ b/Akash Kumar/Noof1.c @@ -0,0 +1,61 @@ +#include +int countSubStr(char str[]) +{ +int res = 0; // Initialize result + +// Pick a starting point +for (int i=0; str[i] !='\0'; i++) +{ + if (str[i] == '1') + { + // Search for all possible ending point + for (int j=i+1; str[j] !='\0'; j++) + if (str[j] == '1') + res++; + } +} +return res; +} + +// Driver program to test above function +int main() +{ +int n; +int i; +int a[10]; +char str[] = "01101"; + +printf("Enter no of Test cases:- "); +scanf("%d",&n); +for(i=0;i +#include +int Number(char *str, char *Substring, int n, int k) +{ + int res=0; + for(int i=0;i<=n-k;i++) + { + int j; + for(j=0;j +#include +#include +int main() +{ + int n; + printf("Enter no of elements of array"); + scanf("%d", &n); + int arr[n]; + int i, x; + for (i = 0; i < n; i++) + { + printf("Enter the %dth element", i + 1); + scanf("%d", &arr[i]); + } + int A, B, C; + printf("Enter A , B and C"); + scanf("%d%d%d", &A, &B, &C); + int p, q, r; + int count = 0; + for (int i = 0; i < n - 2; i++) + { + for (int j = i + 1; j < n - 1; j++) + { + for (int k = j + 1; k < n; k++) + { + p = arr[i] - arr[j]; + q = arr[j] - arr[k]; + r = arr[i] - arr[k]; + if ((abs(p) <= A) && + (abs(q) <= B) && (abs(r) <= C)) + { + count = count + 1; + } + } + } + } + printf("the triple is %d", count); +} diff --git a/Akash Kumar/a.c b/Akash Kumar/a.c new file mode 100644 index 000000000..f5bf270bd --- /dev/null +++ b/Akash Kumar/a.c @@ -0,0 +1,35 @@ +#include +int is_prime(int num) +{ + int i; + for (i = 2; i < num / 2 + 1; i++) + { + if (num % i == 0) + { + return 0; + } + } + return 1; +} +int main() +{ + int i, j, rows, x, num=2; + printf("Enter the number of rows: "); + scanf("%d", &rows); + printf("* \n"); + for (i = 2; i <= rows; i++) + { + for (j = 1; j <= i; ++j) + { + + x = is_prime(num); + if (x == 1) + printf("# "); + else + printf("* "); + num=num+1; + } + printf("\n"); + } + return 0; +} \ No newline at end of file diff --git a/Akash Kumar/candy.c b/Akash Kumar/candy.c new file mode 100644 index 000000000..9c18f50ce --- /dev/null +++ b/Akash Kumar/candy.c @@ -0,0 +1,31 @@ +#include +int main() +{ + int n, i, extraCandies, max = 0; + printf("Enter no of array elements"); + scanf("%d",&n); + int candies[n]; + for (i = 0; i < n; i++) + { + scanf("%d", &candies[i]); + } + printf("Eter no of extraCandies"); + scanf("%d", &extraCandies); + max = candies[0]; + for (i = 0; i < n; i++) + { + if (candies[i] > max) + max = candies[i]; + } + for (int i = 0; i < n; i++) + { + if (candies[i] + extraCandies < max) + { + printf("FALSE"); + } + else + { + printf("TRUE"); + } + } +} diff --git a/Akash Kumar/ip.c b/Akash Kumar/ip.c new file mode 100644 index 000000000..286711c15 --- /dev/null +++ b/Akash Kumar/ip.c @@ -0,0 +1,34 @@ +#include +int main() +{ + int decimalnum, remainder, quotient, Quotient; + int octalNumber[100], i = 1, j; + // printf("Enter the decimal number: "); + scanf("%ld", &decimalnum); + quotient = decimalnum; + while (quotient != 0) + { + octalNumber[i++] = quotient % 8; + quotient = quotient / 8; + } + // printf("Equivalent octal value of decimal no %d: ", decimalnum); + for (j = i - 1; j > 0; j--) + printf("%d", octalNumber[j]); + printf("\n"); + i=0; + j = 0; + char hexadecimalnum[100]; + Quotient = decimalnum; + while (Quotient != 0) + { + remainder = Quotient % 16; + if (remainder < 10) + hexadecimalnum[j++] = 48 + remainder; + else + hexadecimalnum[j++] = 55 + remainder; + Quotient = Quotient / 16; + } + for (i = j; i >= 0; i--) + printf("%c", hexadecimalnum[i]); + return 0; +} \ No newline at end of file diff --git a/Akash Kumar/next.c b/Akash Kumar/next.c new file mode 100644 index 000000000..bafce6470 --- /dev/null +++ b/Akash Kumar/next.c @@ -0,0 +1,16 @@ +#include // stdio.h library is included +int main() +{ //program started + float a,b; //declare variable a, b + float sum, subtract, mutliplication, division; // decare variable sum, subtract, mutliplication, division + printf("Enter a: "); + scanf("%f",&a); //value of a is obtained and stored in its memory + printf("Enter b: "); + scanf("%f",&b); //value of b is obtained and stored in its memory + sum=a+b; // sum is assigned the value a+b + subtract=a-b; // subtract is assigned the value a-b + mutliplication=a*b; // multiplication is assigned the value a*b + division=a/b; // division is assigned the value a/b + printf("Sum is %f \nSubract is %f \nMultiplication is %f \nDivision is %f \n",sum,subtract,mutliplication,division); + return 0; +} // program ended \ No newline at end of file diff --git a/Akash Kumar/oddarray.c b/Akash Kumar/oddarray.c new file mode 100644 index 000000000..f10611140 --- /dev/null +++ b/Akash Kumar/oddarray.c @@ -0,0 +1,26 @@ +#include +int main() +{ + int i, n, sum=0; + printf("Enter no of elemets of array"); + scanf("%d",&n); + int arr[n]; + for(i=0;i +#if A== 1 + #define B 0 +#else + #define B 1 +#endif +int main() +{ + printf("%d", B); + return 0; +} diff --git a/Akash Kumar/triplet.c b/Akash Kumar/triplet.c new file mode 100644 index 000000000..2ef953132 --- /dev/null +++ b/Akash Kumar/triplet.c @@ -0,0 +1,72 @@ +#include +#include +#include +/*int CountTriplets(int arr[], int n, int A, int B, int C) +{ + int p, q, r; + int count = 0; + for(int i = 0; i < n - 2; i++) + { + for(int j=i+1; j < n - 1; j++) + { + for(int k=j+1; k < n; k++) + { + p=arr[i]-arr[j]; + printf("%d",p); + q=arr[j]-arr[k]; + printf("%d", q); + r=arr[i]-arr[k]; + printf("%d",r); + if ((p <= A) && + (q <= B) && (r <= C)) + { + count=count+1; + } + } + } + } + return count; +} +*/ +int main() +{ + int n; + printf("Enter no of elements of array"); + scanf("%d", &n); + int arr[n]; + int i, x; + for (i = 0; i < n; i++) + { + printf("Enter the %dth element", i + 1); + scanf("%d", &arr[i]); + } + int A, B, C; + printf("Enter A , B and C"); + scanf("%d%d%d", &A, &B, &C); + int p, q, r; + int count = 0; + for (int i = 0; i < n - 2; i++) + { + for (int j = i + 1; j < n - 1; j++) + { + for (int k = j + 1; k < n; k++) + { + p = arr[i] - arr[j]; + printf("%d\n", p); + q = arr[j] - arr[k]; + printf("%d\n", q); + r = arr[i] - arr[k]; + printf("%d\n", r); + if ((abs(p) <= A) && + (abs(q) <= B) && (abs(r) <= C)) + { + count = count + 1; + printf("count is %d\n", count); + } + } + } + } + //x = CountTriplets(arr[n], n, A, B, C); + // printf("the triple is %d", x); + printf("the triple is %d", count); +} From 9f9a2e4b98f91575aa2665e806d267acef916293 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:39:17 +0530 Subject: [PATCH 065/110] Add files via upload --- Akash Kumar/Grade_question.c | 24 +++ Akash Kumar/Greatest.c | 30 ++++ Akash Kumar/d.c | 11 ++ Akash Kumar/leap_year.c | 27 ++++ Akash Kumar/ood-or-even.c | 15 ++ Akash Kumar/pointer_first.c | 7 + Akash Kumar/pointer_second.c | 13 ++ Akash Kumar/pyramid.c | 29 ++++ Akash Kumar/star.c | 30 ++++ Akash Kumar/switch.c | 288 +++++++++++++++++++++++++++++++++++ Akash Kumar/switch1.c | 123 +++++++++++++++ 11 files changed, 597 insertions(+) create mode 100644 Akash Kumar/Grade_question.c create mode 100644 Akash Kumar/Greatest.c create mode 100644 Akash Kumar/d.c create mode 100644 Akash Kumar/leap_year.c create mode 100644 Akash Kumar/ood-or-even.c create mode 100644 Akash Kumar/pointer_first.c create mode 100644 Akash Kumar/pointer_second.c create mode 100644 Akash Kumar/pyramid.c create mode 100644 Akash Kumar/star.c create mode 100644 Akash Kumar/switch.c create mode 100644 Akash Kumar/switch1.c diff --git a/Akash Kumar/Grade_question.c b/Akash Kumar/Grade_question.c new file mode 100644 index 000000000..933b69f2e --- /dev/null +++ b/Akash Kumar/Grade_question.c @@ -0,0 +1,24 @@ +#include + +int main () { + int marks; + printf("enter your marks\n"); + scanf("%d", &marks); + if(marks>89 && marks<=100) + { + printf("Your grade is A"); + } + else if(marks>79 && marks<=90) { + printf("Your grade is B"); + } + else if(marks>69 && marks<=80) { + printf("Your grade is C"); + } + else if(marks>50 && marks<=70) { + printf("Your grade is D"); + } + else { + printf("Your grade is F"); + } + return 0; +} \ No newline at end of file diff --git a/Akash Kumar/Greatest.c b/Akash Kumar/Greatest.c new file mode 100644 index 000000000..2a0f9128e --- /dev/null +++ b/Akash Kumar/Greatest.c @@ -0,0 +1,30 @@ +#include +int main () +{ + int a; + int b; + int c; + int d; + int greatest=0; + printf("ENTER 1ST NUMBER"); + scanf("%d", &a); + printf("ENTER 2nd NUMBER"); + scanf("%d", &b); + printf("ENTER 3rd NUMBER"); + scanf("%d", &c); + printf("ENTER 4th NUMBER"); + scanf("%d", &d); + if(a>>b) { + greatest=a; + } + else + { + greatest=b; + } + + + + printf("Greatest number is %d", greatest); + + return 0; +} \ No newline at end of file diff --git a/Akash Kumar/d.c b/Akash Kumar/d.c new file mode 100644 index 000000000..635072fae --- /dev/null +++ b/Akash Kumar/d.c @@ -0,0 +1,11 @@ +#include +#define fun(x)(x*x-x) +int main() { + int x=y=z=8; + + printf("%d%d%d",x,y,z); + + + + return 0; +} \ No newline at end of file diff --git a/Akash Kumar/leap_year.c b/Akash Kumar/leap_year.c new file mode 100644 index 000000000..987dbe5cf --- /dev/null +++ b/Akash Kumar/leap_year.c @@ -0,0 +1,27 @@ +#include +int main() { + int year; + int leap_year=0; + printf("enter year"); + scanf("%d", &year); + + if(year%4==0) { + leap_year=leap_year + 1; + } + if(year%100==0) { + leap_year=leap_year-1; + } + if(year%400==0) { + leap_year=leap_year+1; + } + + if(leap_year==1){ + printf("%d is a leap year", year); + } + else + { + printf("%d is not a leap year", year); + } + +return 0; +} \ No newline at end of file diff --git a/Akash Kumar/ood-or-even.c b/Akash Kumar/ood-or-even.c new file mode 100644 index 000000000..192bd2a42 --- /dev/null +++ b/Akash Kumar/ood-or-even.c @@ -0,0 +1,15 @@ +#include +void main(){ +printf("ODD OR EVEN\n"); +int a; +printf("Enter a\n"); +scanf("%d", &a); +if (a%2==0) +{ + printf("%d is an Even number\n", a); +} +else +{ + printf("%d is an Odd number\n", a); +} +} \ No newline at end of file diff --git a/Akash Kumar/pointer_first.c b/Akash Kumar/pointer_first.c new file mode 100644 index 000000000..3e1fa996e --- /dev/null +++ b/Akash Kumar/pointer_first.c @@ -0,0 +1,7 @@ +#include +int main() { + int a=5; + printf("value of address is %u\n", &a); + printf("value of a is %d", *(&a)); + return 0; +} \ No newline at end of file diff --git a/Akash Kumar/pointer_second.c b/Akash Kumar/pointer_second.c new file mode 100644 index 000000000..0de74607f --- /dev/null +++ b/Akash Kumar/pointer_second.c @@ -0,0 +1,13 @@ +#include +int vae(int a); +int main(){ + int i; + printf("the value of address is %u\n", &i); + vae(i); + printf("the value of address is %u\n", &i); + return 0; +} +int vae(int a) { +printf("the address of a is %u\n", &a); + +} \ No newline at end of file diff --git a/Akash Kumar/pyramid.c b/Akash Kumar/pyramid.c new file mode 100644 index 000000000..ec66085f0 --- /dev/null +++ b/Akash Kumar/pyramid.c @@ -0,0 +1,29 @@ +#include + +#define MAX 10 + +int main() +{ + int i,j; + + for(i=0; i< MAX; i++) + { + for(j=0;j<=i;j++) + { + printf("*"); + } + printf("\n"); + } + + for(i=MAX-1; i>=1 ; i--) + { + + for(j=i;j>0;j--) + { + printf("*"); + } + printf("\n"); + } + + return 0; +} \ No newline at end of file diff --git a/Akash Kumar/star.c b/Akash Kumar/star.c new file mode 100644 index 000000000..faa3ff14f --- /dev/null +++ b/Akash Kumar/star.c @@ -0,0 +1,30 @@ +#include +int main() +{ +int N; //Number of * in the middle row +scanf("%d", &N); //Value of N is taken from test data + +int i,j,k,s=1; + for (i=1; i<=N; i++) { + for (k=s; k=1; i--) { + for (k=s; k>0; k--) { + printf(" "); + } + for (j=i; j>=1; j--) { + printf("*"); + } + s = s + 1; + printf("\n"); + } + +} \ No newline at end of file diff --git a/Akash Kumar/switch.c b/Akash Kumar/switch.c new file mode 100644 index 000000000..3d0538689 --- /dev/null +++ b/Akash Kumar/switch.c @@ -0,0 +1,288 @@ +#include + +int main(void) +{ + int num; + + printf("Enter a two-digit number: "); + scanf("%d", &num); + + printf("You have entered: "); + + switch (num) + { + case 10: + printf("ten"); + return 0; + case 11: + printf("eleven"); + return 0; + case 12: + printf("twelve"); + return 0; + case 13: + printf("thirteen"); + return 0; + case 14: + printf("fourteen"); + return 0; + case 15: + printf("fifteen"); + return 0; + case 16: + printf("sixteen"); + return 0; + case 17: + printf("seventeen"); + return 0; + case 18: + printf("eigthteen"); + return 0; + case 19: + printf("nineteen"); + return 0; + case 20: + printf("twenty"); + break; + case 21: + printf("Twenty-one"); + break; + case 22: + printf("Twenty-two"); + break; + case 23: + printf("Twenty-three"); + break; + case 24: + printf("Twenty-four"); + break; + case 25: + printf("Twenty-five"); + break; + case 26: + printf("Twenty-six"); + break; + case 27: + printf("Twenty-seven"); + break; + case 28: + printf("Twenty-eight"); + break; + case 29: + printf("Twenty-nine"); + break; + case 30: + printf("thirty"); + break; + case 31: + printf("Thirty-one"); + break; + case 32: + printf("Thirty-two"); + break; + case 33: + printf("Thirty-three"); + break; + case 34: + printf("Thirty-four"); + break; + case 35: + printf("Thirty-five"); + break; + case 36: + printf("Thirty-six"); + break; + case 37: + printf("Thirty-seven"); + break; + case 38: + printf("Thirty-eight"); + break; + case 39: + printf("Thirty-nine"); + break; + case 40: + printf("forty"); + break; + + case 41: + printf("Fourty-one"); + break; + case 42: + printf("Fourty-two"); + break; + case 43: + printf("Fourty-three"); + break; + case 44: + printf("Fourty-four"); + break; + case 45: + printf("Fourty-five"); + break; + case 46: + printf("Fourty-six"); + break; + case 47: + printf("Fourty-seven"); + break; + case 48: + printf("Fourty-eight"); + break; + case 49: + printf("Fourty-nine"); + break; + case 50: + printf("fifty"); + break; + case 51: + printf("Fifty-one"); + break; + case 52: + printf("Fifty-two"); + break; + case 53: + printf("Fifty-three"); + break; + case 54: + printf("Fifty-four"); + break; + case 55: + printf("Fifty-five"); + break; + case 56: + printf("Fifty-six"); + break; + case 57: + printf("Fifty-seven"); + break; + case 58: + printf("Fifty-eight"); + break; + case 60: + printf("sixty"); + break; + case 59: + printf("Fifty-nine"); + break; + case 61: + printf("Sixty-one"); + break; + case 62: + printf("Sixty-two"); + break; + case 63: + printf("Sixty-three"); + break; + case 64: + printf("Sixty-four"); + break; + case 65: + printf("Sixty-five"); + break; + case 66: + printf("Sixty-six"); + break; + case 67: + printf("Sixty-seven"); + break; + case 68: + printf("Sixty-eight"); + break; + case 69: + printf("Sixty-nine"); + break; + case 70: + printf("seventy"); + break; + case 71: + printf("Seventy-one"); + break; + case 72: + printf("Seventy-two"); + break; + case 73: + printf("Seventy-three"); + break; + case 74: + printf("Seventy-four"); + break; + case 75: + printf("Seventy-five"); + break; + case 76: + printf("Seventy-six"); + break; + case 77: + printf("Seventy-seven"); + break; + case 78: + printf("Seventy-eight"); + break; + case 79: + printf("Seventy-nine"); + break; + case 80: + printf("eighty"); + break; + case 81: + printf("Eighty-one"); + break; + case 82: + printf("Eighty-two"); + break; + case 83: + printf("Eighty-three"); + break; + case 84: + printf("Eighty-four"); + break; + case 85: + printf("Eighty-five"); + break; + case 86: + printf("Eighty-six"); + break; + case 87: + printf("Eighty-seven"); + break; + case 88: + printf("Eighty-eight"); + break; + case 89: + printf("Eighty-nine"); + break; + case 90: + printf("ninety"); + break; + case 91: + printf("Ninety-one"); + break; + case 92: + printf("Ninety-two"); + break; + case 93: + printf("Ninety-three"); + break; + case 94: + printf("Ninety-four"); + break; + case 95: + printf("Ninety-five"); + break; + case 96: + printf("Ninety-six"); + break; + case 97: + printf("Ninety-seven"); + break; + case 98: + printf("Ninety-eight"); + break; + case 99: + printf("Ninety-nine"); + break; + } + + return 0; +} \ No newline at end of file diff --git a/Akash Kumar/switch1.c b/Akash Kumar/switch1.c new file mode 100644 index 000000000..1ae1234df --- /dev/null +++ b/Akash Kumar/switch1.c @@ -0,0 +1,123 @@ +#include + +int main(void) +{ + int num; + + printf("Enter a two-digit number: "); + scanf("%d", &num); + + printf("You have entered: "); + if (num < 20) + { + switch (num) + { + case 10: + printf("ten"); + return 0; + case 11: + printf("eleven"); + return 0; + case 12: + printf("twelve"); + return 0; + case 13: + printf("thirteen"); + return 0; + case 14: + printf("fourteen"); + return 0; + case 15: + printf("fifteen"); + return 0; + case 16: + printf("sixteen"); + return 0; + case 17: + printf("seventeen"); + return 0; + case 18: + printf("eigthteen"); + return 0; + case 19: + printf("nineteen"); + return 0; + } + } + else + { + switch (num / 10) + { + + case 2: + printf("twenty"); + break; + + case 3: + printf("thirty"); + break; + + case 4: + printf("forty"); + break; + + case 5: + printf("fifty"); + break; + + case 6: + printf("Sixty"); + break; + case 7: + printf("seventy"); + break; + + case 8: + printf("eighty"); + break; + + case 9: + printf("ninety"); + break; + } + switch (num % 10) + { + + case 1: + printf("-one"); + break; + case 2: + printf("-two"); + break; + + case 3: + printf("-three"); + break; + + case 4: + printf("-four"); + break; + + case 5: + printf("-five"); + break; + + case 6: + printf("-Six"); + break; + case 7: + printf("-seven"); + break; + + case 8: + printf("-eight"); + break; + + case 9: + printf("-nine"); + break; + } + } + + return 0; +} \ No newline at end of file From 08ae9e744ea07e01044ad0c35d20a2f3e450eaf5 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:57:54 +0530 Subject: [PATCH 066/110] Delete Grade_question.c --- Akash Kumar/Grade_question.c | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 Akash Kumar/Grade_question.c diff --git a/Akash Kumar/Grade_question.c b/Akash Kumar/Grade_question.c deleted file mode 100644 index 933b69f2e..000000000 --- a/Akash Kumar/Grade_question.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -int main () { - int marks; - printf("enter your marks\n"); - scanf("%d", &marks); - if(marks>89 && marks<=100) - { - printf("Your grade is A"); - } - else if(marks>79 && marks<=90) { - printf("Your grade is B"); - } - else if(marks>69 && marks<=80) { - printf("Your grade is C"); - } - else if(marks>50 && marks<=70) { - printf("Your grade is D"); - } - else { - printf("Your grade is F"); - } - return 0; -} \ No newline at end of file From 9a844debcaff8da49bd6ba69c46bd5e6874fb2d8 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:58:04 +0530 Subject: [PATCH 067/110] Delete Noof1.c --- Akash Kumar/Noof1.c | 61 --------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 Akash Kumar/Noof1.c diff --git a/Akash Kumar/Noof1.c b/Akash Kumar/Noof1.c deleted file mode 100644 index c789ea45b..000000000 --- a/Akash Kumar/Noof1.c +++ /dev/null @@ -1,61 +0,0 @@ -#include -int countSubStr(char str[]) -{ -int res = 0; // Initialize result - -// Pick a starting point -for (int i=0; str[i] !='\0'; i++) -{ - if (str[i] == '1') - { - // Search for all possible ending point - for (int j=i+1; str[j] !='\0'; j++) - if (str[j] == '1') - res++; - } -} -return res; -} - -// Driver program to test above function -int main() -{ -int n; -int i; -int a[10]; -char str[] = "01101"; - -printf("Enter no of Test cases:- "); -scanf("%d",&n); -for(i=0;i Date: Tue, 4 May 2021 22:58:10 +0530 Subject: [PATCH 068/110] Delete Occurancesubaaray.c --- Akash Kumar/Occurancesubaaray.c | 42 --------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 Akash Kumar/Occurancesubaaray.c diff --git a/Akash Kumar/Occurancesubaaray.c b/Akash Kumar/Occurancesubaaray.c deleted file mode 100644 index d36597dae..000000000 --- a/Akash Kumar/Occurancesubaaray.c +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -int Number(char *str, char *Substring, int n, int k) -{ - int res=0; - for(int i=0;i<=n-k;i++) - { - int j; - for(j=0;j Date: Tue, 4 May 2021 22:58:15 +0530 Subject: [PATCH 069/110] Delete Question2.c --- Akash Kumar/Question2.c | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 Akash Kumar/Question2.c diff --git a/Akash Kumar/Question2.c b/Akash Kumar/Question2.c deleted file mode 100644 index a7eea7ad8..000000000 --- a/Akash Kumar/Question2.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -int main() -{ - int n; - printf("Enter no of elements of array"); - scanf("%d", &n); - int arr[n]; - int i, x; - for (i = 0; i < n; i++) - { - printf("Enter the %dth element", i + 1); - scanf("%d", &arr[i]); - } - int A, B, C; - printf("Enter A , B and C"); - scanf("%d%d%d", &A, &B, &C); - int p, q, r; - int count = 0; - for (int i = 0; i < n - 2; i++) - { - for (int j = i + 1; j < n - 1; j++) - { - for (int k = j + 1; k < n; k++) - { - p = arr[i] - arr[j]; - q = arr[j] - arr[k]; - r = arr[i] - arr[k]; - if ((abs(p) <= A) && - (abs(q) <= B) && (abs(r) <= C)) - { - count = count + 1; - } - } - } - } - printf("the triple is %d", count); -} From 92afd62976dbcc542a780087a02d79d67810cc97 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:58:20 +0530 Subject: [PATCH 070/110] Delete a.c --- Akash Kumar/a.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 Akash Kumar/a.c diff --git a/Akash Kumar/a.c b/Akash Kumar/a.c deleted file mode 100644 index f5bf270bd..000000000 --- a/Akash Kumar/a.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -int is_prime(int num) -{ - int i; - for (i = 2; i < num / 2 + 1; i++) - { - if (num % i == 0) - { - return 0; - } - } - return 1; -} -int main() -{ - int i, j, rows, x, num=2; - printf("Enter the number of rows: "); - scanf("%d", &rows); - printf("* \n"); - for (i = 2; i <= rows; i++) - { - for (j = 1; j <= i; ++j) - { - - x = is_prime(num); - if (x == 1) - printf("# "); - else - printf("* "); - num=num+1; - } - printf("\n"); - } - return 0; -} \ No newline at end of file From 7959dd21c813709259cc2861cf3f63d6359bcef7 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:58:24 +0530 Subject: [PATCH 071/110] Delete candy.c --- Akash Kumar/candy.c | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 Akash Kumar/candy.c diff --git a/Akash Kumar/candy.c b/Akash Kumar/candy.c deleted file mode 100644 index 9c18f50ce..000000000 --- a/Akash Kumar/candy.c +++ /dev/null @@ -1,31 +0,0 @@ -#include -int main() -{ - int n, i, extraCandies, max = 0; - printf("Enter no of array elements"); - scanf("%d",&n); - int candies[n]; - for (i = 0; i < n; i++) - { - scanf("%d", &candies[i]); - } - printf("Eter no of extraCandies"); - scanf("%d", &extraCandies); - max = candies[0]; - for (i = 0; i < n; i++) - { - if (candies[i] > max) - max = candies[i]; - } - for (int i = 0; i < n; i++) - { - if (candies[i] + extraCandies < max) - { - printf("FALSE"); - } - else - { - printf("TRUE"); - } - } -} From 74a9adcfc7b419aa60987ac343bc2a4aeac14eac Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:58:28 +0530 Subject: [PATCH 072/110] Delete d.c --- Akash Kumar/d.c | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 Akash Kumar/d.c diff --git a/Akash Kumar/d.c b/Akash Kumar/d.c deleted file mode 100644 index 635072fae..000000000 --- a/Akash Kumar/d.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#define fun(x)(x*x-x) -int main() { - int x=y=z=8; - - printf("%d%d%d",x,y,z); - - - - return 0; -} \ No newline at end of file From 806c552fb3db2730eb56d60ea7ec515744508f8e Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:58:33 +0530 Subject: [PATCH 073/110] Delete ip.c --- Akash Kumar/ip.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 Akash Kumar/ip.c diff --git a/Akash Kumar/ip.c b/Akash Kumar/ip.c deleted file mode 100644 index 286711c15..000000000 --- a/Akash Kumar/ip.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -int main() -{ - int decimalnum, remainder, quotient, Quotient; - int octalNumber[100], i = 1, j; - // printf("Enter the decimal number: "); - scanf("%ld", &decimalnum); - quotient = decimalnum; - while (quotient != 0) - { - octalNumber[i++] = quotient % 8; - quotient = quotient / 8; - } - // printf("Equivalent octal value of decimal no %d: ", decimalnum); - for (j = i - 1; j > 0; j--) - printf("%d", octalNumber[j]); - printf("\n"); - i=0; - j = 0; - char hexadecimalnum[100]; - Quotient = decimalnum; - while (Quotient != 0) - { - remainder = Quotient % 16; - if (remainder < 10) - hexadecimalnum[j++] = 48 + remainder; - else - hexadecimalnum[j++] = 55 + remainder; - Quotient = Quotient / 16; - } - for (i = j; i >= 0; i--) - printf("%c", hexadecimalnum[i]); - return 0; -} \ No newline at end of file From 42a836aefd7e4c36e34713e95bcabb70286b88ad Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:58:37 +0530 Subject: [PATCH 074/110] Delete leap_year.c --- Akash Kumar/leap_year.c | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 Akash Kumar/leap_year.c diff --git a/Akash Kumar/leap_year.c b/Akash Kumar/leap_year.c deleted file mode 100644 index 987dbe5cf..000000000 --- a/Akash Kumar/leap_year.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -int main() { - int year; - int leap_year=0; - printf("enter year"); - scanf("%d", &year); - - if(year%4==0) { - leap_year=leap_year + 1; - } - if(year%100==0) { - leap_year=leap_year-1; - } - if(year%400==0) { - leap_year=leap_year+1; - } - - if(leap_year==1){ - printf("%d is a leap year", year); - } - else - { - printf("%d is not a leap year", year); - } - -return 0; -} \ No newline at end of file From e2371f710aac9c5607f74456807e206d3f3d440f Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:58:42 +0530 Subject: [PATCH 075/110] Delete next.c --- Akash Kumar/next.c | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 Akash Kumar/next.c diff --git a/Akash Kumar/next.c b/Akash Kumar/next.c deleted file mode 100644 index bafce6470..000000000 --- a/Akash Kumar/next.c +++ /dev/null @@ -1,16 +0,0 @@ -#include // stdio.h library is included -int main() -{ //program started - float a,b; //declare variable a, b - float sum, subtract, mutliplication, division; // decare variable sum, subtract, mutliplication, division - printf("Enter a: "); - scanf("%f",&a); //value of a is obtained and stored in its memory - printf("Enter b: "); - scanf("%f",&b); //value of b is obtained and stored in its memory - sum=a+b; // sum is assigned the value a+b - subtract=a-b; // subtract is assigned the value a-b - mutliplication=a*b; // multiplication is assigned the value a*b - division=a/b; // division is assigned the value a/b - printf("Sum is %f \nSubract is %f \nMultiplication is %f \nDivision is %f \n",sum,subtract,mutliplication,division); - return 0; -} // program ended \ No newline at end of file From f42a53cc8b162d923090d10ece8ed33fc0f72a4a Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:58:47 +0530 Subject: [PATCH 076/110] Delete oddarray.c --- Akash Kumar/oddarray.c | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 Akash Kumar/oddarray.c diff --git a/Akash Kumar/oddarray.c b/Akash Kumar/oddarray.c deleted file mode 100644 index f10611140..000000000 --- a/Akash Kumar/oddarray.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -int main() -{ - int i, n, sum=0; - printf("Enter no of elemets of array"); - scanf("%d",&n); - int arr[n]; - for(i=0;i Date: Tue, 4 May 2021 22:58:52 +0530 Subject: [PATCH 077/110] Delete ood-or-even.c --- Akash Kumar/ood-or-even.c | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Akash Kumar/ood-or-even.c diff --git a/Akash Kumar/ood-or-even.c b/Akash Kumar/ood-or-even.c deleted file mode 100644 index 192bd2a42..000000000 --- a/Akash Kumar/ood-or-even.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -void main(){ -printf("ODD OR EVEN\n"); -int a; -printf("Enter a\n"); -scanf("%d", &a); -if (a%2==0) -{ - printf("%d is an Even number\n", a); -} -else -{ - printf("%d is an Odd number\n", a); -} -} \ No newline at end of file From 3a8268b4940b7ed2db6bc84f65ebe6e700c9f3c0 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:58:57 +0530 Subject: [PATCH 078/110] Delete pointer_first.c --- Akash Kumar/pointer_first.c | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 Akash Kumar/pointer_first.c diff --git a/Akash Kumar/pointer_first.c b/Akash Kumar/pointer_first.c deleted file mode 100644 index 3e1fa996e..000000000 --- a/Akash Kumar/pointer_first.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -int main() { - int a=5; - printf("value of address is %u\n", &a); - printf("value of a is %d", *(&a)); - return 0; -} \ No newline at end of file From 5dd0ec29368adff48c9583a967d1d11d4d50e816 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:59:01 +0530 Subject: [PATCH 079/110] Delete pointer_second.c --- Akash Kumar/pointer_second.c | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 Akash Kumar/pointer_second.c diff --git a/Akash Kumar/pointer_second.c b/Akash Kumar/pointer_second.c deleted file mode 100644 index 0de74607f..000000000 --- a/Akash Kumar/pointer_second.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -int vae(int a); -int main(){ - int i; - printf("the value of address is %u\n", &i); - vae(i); - printf("the value of address is %u\n", &i); - return 0; -} -int vae(int a) { -printf("the address of a is %u\n", &a); - -} \ No newline at end of file From eec9fc7078584ea71930922689f0c1fcfa368cb3 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:59:06 +0530 Subject: [PATCH 080/110] Delete pyramid.c --- Akash Kumar/pyramid.c | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 Akash Kumar/pyramid.c diff --git a/Akash Kumar/pyramid.c b/Akash Kumar/pyramid.c deleted file mode 100644 index ec66085f0..000000000 --- a/Akash Kumar/pyramid.c +++ /dev/null @@ -1,29 +0,0 @@ -#include - -#define MAX 10 - -int main() -{ - int i,j; - - for(i=0; i< MAX; i++) - { - for(j=0;j<=i;j++) - { - printf("*"); - } - printf("\n"); - } - - for(i=MAX-1; i>=1 ; i--) - { - - for(j=i;j>0;j--) - { - printf("*"); - } - printf("\n"); - } - - return 0; -} \ No newline at end of file From 387a36c85baabc12d310147e4f7bb65ae41e8d57 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:59:11 +0530 Subject: [PATCH 081/110] Delete star.c --- Akash Kumar/star.c | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 Akash Kumar/star.c diff --git a/Akash Kumar/star.c b/Akash Kumar/star.c deleted file mode 100644 index faa3ff14f..000000000 --- a/Akash Kumar/star.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -int main() -{ -int N; //Number of * in the middle row -scanf("%d", &N); //Value of N is taken from test data - -int i,j,k,s=1; - for (i=1; i<=N; i++) { - for (k=s; k=1; i--) { - for (k=s; k>0; k--) { - printf(" "); - } - for (j=i; j>=1; j--) { - printf("*"); - } - s = s + 1; - printf("\n"); - } - -} \ No newline at end of file From 1875d356626e630e2aad742af331750972389335 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:59:15 +0530 Subject: [PATCH 082/110] Delete switch.c --- Akash Kumar/switch.c | 288 ------------------------------------------- 1 file changed, 288 deletions(-) delete mode 100644 Akash Kumar/switch.c diff --git a/Akash Kumar/switch.c b/Akash Kumar/switch.c deleted file mode 100644 index 3d0538689..000000000 --- a/Akash Kumar/switch.c +++ /dev/null @@ -1,288 +0,0 @@ -#include - -int main(void) -{ - int num; - - printf("Enter a two-digit number: "); - scanf("%d", &num); - - printf("You have entered: "); - - switch (num) - { - case 10: - printf("ten"); - return 0; - case 11: - printf("eleven"); - return 0; - case 12: - printf("twelve"); - return 0; - case 13: - printf("thirteen"); - return 0; - case 14: - printf("fourteen"); - return 0; - case 15: - printf("fifteen"); - return 0; - case 16: - printf("sixteen"); - return 0; - case 17: - printf("seventeen"); - return 0; - case 18: - printf("eigthteen"); - return 0; - case 19: - printf("nineteen"); - return 0; - case 20: - printf("twenty"); - break; - case 21: - printf("Twenty-one"); - break; - case 22: - printf("Twenty-two"); - break; - case 23: - printf("Twenty-three"); - break; - case 24: - printf("Twenty-four"); - break; - case 25: - printf("Twenty-five"); - break; - case 26: - printf("Twenty-six"); - break; - case 27: - printf("Twenty-seven"); - break; - case 28: - printf("Twenty-eight"); - break; - case 29: - printf("Twenty-nine"); - break; - case 30: - printf("thirty"); - break; - case 31: - printf("Thirty-one"); - break; - case 32: - printf("Thirty-two"); - break; - case 33: - printf("Thirty-three"); - break; - case 34: - printf("Thirty-four"); - break; - case 35: - printf("Thirty-five"); - break; - case 36: - printf("Thirty-six"); - break; - case 37: - printf("Thirty-seven"); - break; - case 38: - printf("Thirty-eight"); - break; - case 39: - printf("Thirty-nine"); - break; - case 40: - printf("forty"); - break; - - case 41: - printf("Fourty-one"); - break; - case 42: - printf("Fourty-two"); - break; - case 43: - printf("Fourty-three"); - break; - case 44: - printf("Fourty-four"); - break; - case 45: - printf("Fourty-five"); - break; - case 46: - printf("Fourty-six"); - break; - case 47: - printf("Fourty-seven"); - break; - case 48: - printf("Fourty-eight"); - break; - case 49: - printf("Fourty-nine"); - break; - case 50: - printf("fifty"); - break; - case 51: - printf("Fifty-one"); - break; - case 52: - printf("Fifty-two"); - break; - case 53: - printf("Fifty-three"); - break; - case 54: - printf("Fifty-four"); - break; - case 55: - printf("Fifty-five"); - break; - case 56: - printf("Fifty-six"); - break; - case 57: - printf("Fifty-seven"); - break; - case 58: - printf("Fifty-eight"); - break; - case 60: - printf("sixty"); - break; - case 59: - printf("Fifty-nine"); - break; - case 61: - printf("Sixty-one"); - break; - case 62: - printf("Sixty-two"); - break; - case 63: - printf("Sixty-three"); - break; - case 64: - printf("Sixty-four"); - break; - case 65: - printf("Sixty-five"); - break; - case 66: - printf("Sixty-six"); - break; - case 67: - printf("Sixty-seven"); - break; - case 68: - printf("Sixty-eight"); - break; - case 69: - printf("Sixty-nine"); - break; - case 70: - printf("seventy"); - break; - case 71: - printf("Seventy-one"); - break; - case 72: - printf("Seventy-two"); - break; - case 73: - printf("Seventy-three"); - break; - case 74: - printf("Seventy-four"); - break; - case 75: - printf("Seventy-five"); - break; - case 76: - printf("Seventy-six"); - break; - case 77: - printf("Seventy-seven"); - break; - case 78: - printf("Seventy-eight"); - break; - case 79: - printf("Seventy-nine"); - break; - case 80: - printf("eighty"); - break; - case 81: - printf("Eighty-one"); - break; - case 82: - printf("Eighty-two"); - break; - case 83: - printf("Eighty-three"); - break; - case 84: - printf("Eighty-four"); - break; - case 85: - printf("Eighty-five"); - break; - case 86: - printf("Eighty-six"); - break; - case 87: - printf("Eighty-seven"); - break; - case 88: - printf("Eighty-eight"); - break; - case 89: - printf("Eighty-nine"); - break; - case 90: - printf("ninety"); - break; - case 91: - printf("Ninety-one"); - break; - case 92: - printf("Ninety-two"); - break; - case 93: - printf("Ninety-three"); - break; - case 94: - printf("Ninety-four"); - break; - case 95: - printf("Ninety-five"); - break; - case 96: - printf("Ninety-six"); - break; - case 97: - printf("Ninety-seven"); - break; - case 98: - printf("Ninety-eight"); - break; - case 99: - printf("Ninety-nine"); - break; - } - - return 0; -} \ No newline at end of file From 46cb0b5b00365d56f1965109188e2d3b84857cf2 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:59:20 +0530 Subject: [PATCH 083/110] Delete switch1.c --- Akash Kumar/switch1.c | 123 ------------------------------------------ 1 file changed, 123 deletions(-) delete mode 100644 Akash Kumar/switch1.c diff --git a/Akash Kumar/switch1.c b/Akash Kumar/switch1.c deleted file mode 100644 index 1ae1234df..000000000 --- a/Akash Kumar/switch1.c +++ /dev/null @@ -1,123 +0,0 @@ -#include - -int main(void) -{ - int num; - - printf("Enter a two-digit number: "); - scanf("%d", &num); - - printf("You have entered: "); - if (num < 20) - { - switch (num) - { - case 10: - printf("ten"); - return 0; - case 11: - printf("eleven"); - return 0; - case 12: - printf("twelve"); - return 0; - case 13: - printf("thirteen"); - return 0; - case 14: - printf("fourteen"); - return 0; - case 15: - printf("fifteen"); - return 0; - case 16: - printf("sixteen"); - return 0; - case 17: - printf("seventeen"); - return 0; - case 18: - printf("eigthteen"); - return 0; - case 19: - printf("nineteen"); - return 0; - } - } - else - { - switch (num / 10) - { - - case 2: - printf("twenty"); - break; - - case 3: - printf("thirty"); - break; - - case 4: - printf("forty"); - break; - - case 5: - printf("fifty"); - break; - - case 6: - printf("Sixty"); - break; - case 7: - printf("seventy"); - break; - - case 8: - printf("eighty"); - break; - - case 9: - printf("ninety"); - break; - } - switch (num % 10) - { - - case 1: - printf("-one"); - break; - case 2: - printf("-two"); - break; - - case 3: - printf("-three"); - break; - - case 4: - printf("-four"); - break; - - case 5: - printf("-five"); - break; - - case 6: - printf("-Six"); - break; - case 7: - printf("-seven"); - break; - - case 8: - printf("-eight"); - break; - - case 9: - printf("-nine"); - break; - } - } - - return 0; -} \ No newline at end of file From be60ff38afe745890fac62a7cef1893c3ee65e41 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:59:25 +0530 Subject: [PATCH 084/110] Delete tempCodeRunnerFile.c --- Akash Kumar/tempCodeRunnerFile.c | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 Akash Kumar/tempCodeRunnerFile.c diff --git a/Akash Kumar/tempCodeRunnerFile.c b/Akash Kumar/tempCodeRunnerFile.c deleted file mode 100644 index 8650c23d8..000000000 --- a/Akash Kumar/tempCodeRunnerFile.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#if A== 1 - #define B 0 -#else - #define B 1 -#endif -int main() -{ - printf("%d", B); - return 0; -} From 2ea7fe0663f910ea2b3045f9566246dfbe82b8d8 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 22:59:29 +0530 Subject: [PATCH 085/110] Delete triplet.c --- Akash Kumar/triplet.c | 72 ------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 Akash Kumar/triplet.c diff --git a/Akash Kumar/triplet.c b/Akash Kumar/triplet.c deleted file mode 100644 index 2ef953132..000000000 --- a/Akash Kumar/triplet.c +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -/*int CountTriplets(int arr[], int n, int A, int B, int C) -{ - int p, q, r; - int count = 0; - for(int i = 0; i < n - 2; i++) - { - for(int j=i+1; j < n - 1; j++) - { - for(int k=j+1; k < n; k++) - { - p=arr[i]-arr[j]; - printf("%d",p); - q=arr[j]-arr[k]; - printf("%d", q); - r=arr[i]-arr[k]; - printf("%d",r); - if ((p <= A) && - (q <= B) && (r <= C)) - { - count=count+1; - } - } - } - } - return count; -} -*/ -int main() -{ - int n; - printf("Enter no of elements of array"); - scanf("%d", &n); - int arr[n]; - int i, x; - for (i = 0; i < n; i++) - { - printf("Enter the %dth element", i + 1); - scanf("%d", &arr[i]); - } - int A, B, C; - printf("Enter A , B and C"); - scanf("%d%d%d", &A, &B, &C); - int p, q, r; - int count = 0; - for (int i = 0; i < n - 2; i++) - { - for (int j = i + 1; j < n - 1; j++) - { - for (int k = j + 1; k < n; k++) - { - p = arr[i] - arr[j]; - printf("%d\n", p); - q = arr[j] - arr[k]; - printf("%d\n", q); - r = arr[i] - arr[k]; - printf("%d\n", r); - if ((abs(p) <= A) && - (abs(q) <= B) && (abs(r) <= C)) - { - count = count + 1; - printf("count is %d\n", count); - } - } - } - } - //x = CountTriplets(arr[n], n, A, B, C); - // printf("the triple is %d", x); - printf("the triple is %d", count); -} From 872f74dff6f7302f2baa8c966f19d2d445e79411 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:00:04 +0530 Subject: [PATCH 086/110] Delete Fib.c --- Akash Kumar/Fib.c | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 Akash Kumar/Fib.c diff --git a/Akash Kumar/Fib.c b/Akash Kumar/Fib.c deleted file mode 100644 index 0d7baa91b..000000000 --- a/Akash Kumar/Fib.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -int main() { - int i, n=50, t1 = 0, t2 = 1, nextTerm; - printf("Fibonacci Series: "); - - for (i = 1; i <= n; ++i) { - printf("%d, ", t1); - nextTerm = t1 + t2; - t1 = t2; - t2 = nextTerm; - } - - return 0; -} \ No newline at end of file From 8b2e27535807692e6e32088549410c85047de874 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:00:12 +0530 Subject: [PATCH 087/110] Delete Greatest.c --- Akash Kumar/Greatest.c | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 Akash Kumar/Greatest.c diff --git a/Akash Kumar/Greatest.c b/Akash Kumar/Greatest.c deleted file mode 100644 index 2a0f9128e..000000000 --- a/Akash Kumar/Greatest.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -int main () -{ - int a; - int b; - int c; - int d; - int greatest=0; - printf("ENTER 1ST NUMBER"); - scanf("%d", &a); - printf("ENTER 2nd NUMBER"); - scanf("%d", &b); - printf("ENTER 3rd NUMBER"); - scanf("%d", &c); - printf("ENTER 4th NUMBER"); - scanf("%d", &d); - if(a>>b) { - greatest=a; - } - else - { - greatest=b; - } - - - - printf("Greatest number is %d", greatest); - - return 0; -} \ No newline at end of file From f8e093668c69b6d2c1a50d3e30790b1901af82c0 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:01:59 +0530 Subject: [PATCH 088/110] Create q1.c --- Akash Kumar/q1.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Akash Kumar/q1.c diff --git a/Akash Kumar/q1.c b/Akash Kumar/q1.c new file mode 100644 index 000000000..ddad58102 --- /dev/null +++ b/Akash Kumar/q1.c @@ -0,0 +1,35 @@ +#include +int is_prime(int num) +{ + int i; + for (i = 2; i < num / 2 + 1; i++) + { + if (num % i == 0) + { + return 0; + } + } + return 1; +} +int main() +{ + int i, j, rows, x, num=2; + printf("Enter the number of rows: "); + scanf("%d", &rows); + printf("* \n"); + for (i = 2; i <= rows; i++) + { + for (j = 1; j <= i; ++j) + { + + x = is_prime(num); + if (x == 1) + printf("# "); + else + printf("* "); + num=num+1; + } + printf("\n"); + } + return 0; +} From 54989d4dc6f0ac8f2191190618024018268de601 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:02:30 +0530 Subject: [PATCH 089/110] Create q2.c --- Akash Kumar/q2.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Akash Kumar/q2.c diff --git a/Akash Kumar/q2.c b/Akash Kumar/q2.c new file mode 100644 index 000000000..67ea23f43 --- /dev/null +++ b/Akash Kumar/q2.c @@ -0,0 +1,31 @@ +#include +int main() +{ + int n, i, extraCandies, max = 0; + printf("Enter no of array elements"); + scanf("%d",&n); + int candies[n]; + for (i = 0; i < n; i++) + { + scanf("%d", &candies[i]); + } + printf("Eter no of extraCandies"); + scanf("%d", &extraCandies); + max = candies[0]; + for (i = 0; i < n; i++) + { + if (candies[i] > max) + max = candies[i]; + } + for (int i = 0; i < n; i++) + { + if (candies[i] + extraCandies < max) + { + printf("FALSE"); + } + else + { + printf("TRUE"); + } + } +} From 5a949370f63f8db86b6a421d9d96e493a8695bf1 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:02:51 +0530 Subject: [PATCH 090/110] Create q3.c --- Akash Kumar/q3.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Akash Kumar/q3.c diff --git a/Akash Kumar/q3.c b/Akash Kumar/q3.c new file mode 100644 index 000000000..8902e6da6 --- /dev/null +++ b/Akash Kumar/q3.c @@ -0,0 +1,14 @@ +#include +int main() { + int i, n=50, t1 = 0, t2 = 1, nextTerm; + printf("Fibonacci Series: "); + + for (i = 1; i <= n; ++i) { + printf("%d, ", t1); + nextTerm = t1 + t2; + t1 = t2; + t2 = nextTerm; + } + + return 0; +} From 93345493c94645baef3fae2867269defb2efd5ae Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:03:53 +0530 Subject: [PATCH 091/110] Create q4.c --- Akash Kumar/q4.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Akash Kumar/q4.c diff --git a/Akash Kumar/q4.c b/Akash Kumar/q4.c new file mode 100644 index 000000000..81366aeb5 --- /dev/null +++ b/Akash Kumar/q4.c @@ -0,0 +1,34 @@ +#include +int main() +{ + int decimalnum, remainder, quotient, Quotient; + int octalNumber[100], i = 1, j; + // printf("Enter the decimal number: "); + scanf("%ld", &decimalnum); + quotient = decimalnum; + while (quotient != 0) + { + octalNumber[i++] = quotient % 8; + quotient = quotient / 8; + } + // printf("Equivalent octal value of decimal no %d: ", decimalnum); + for (j = i - 1; j > 0; j--) + printf("%d", octalNumber[j]); + printf("\n"); + i=0; + j = 0; + char hexadecimalnum[100]; + Quotient = decimalnum; + while (Quotient != 0) + { + remainder = Quotient % 16; + if (remainder < 10) + hexadecimalnum[j++] = 48 + remainder; + else + hexadecimalnum[j++] = 55 + remainder; + Quotient = Quotient / 16; + } + for (i = j; i >= 0; i--) + printf("%c", hexadecimalnum[i]); + return 0; +} From 549ac91167f6d487a09bbb0718fb71143df09d18 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:04:19 +0530 Subject: [PATCH 092/110] Create q5.c --- Akash Kumar/q5.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Akash Kumar/q5.c diff --git a/Akash Kumar/q5.c b/Akash Kumar/q5.c new file mode 100644 index 000000000..610eaf963 --- /dev/null +++ b/Akash Kumar/q5.c @@ -0,0 +1,16 @@ +#include // stdio.h library is included +int main() +{ //program started + float a,b; //declare variable a, b + float sum, subtract, mutliplication, division; // decare variable sum, subtract, mutliplication, division + printf("Enter a: "); + scanf("%f",&a); //value of a is obtained and stored in its memory + printf("Enter b: "); + scanf("%f",&b); //value of b is obtained and stored in its memory + sum=a+b; // sum is assigned the value a+b + subtract=a-b; // subtract is assigned the value a-b + mutliplication=a*b; // multiplication is assigned the value a*b + division=a/b; // division is assigned the value a/b + printf("Sum is %f \nSubract is %f \nMultiplication is %f \nDivision is %f \n",sum,subtract,mutliplication,division); + return 0; +} // program ended From 673dc12d6eb5064d40ec3116e28581d1202465af Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:04:46 +0530 Subject: [PATCH 093/110] Create q6.c --- Akash Kumar/q6.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Akash Kumar/q6.c diff --git a/Akash Kumar/q6.c b/Akash Kumar/q6.c new file mode 100644 index 000000000..d6b01c269 --- /dev/null +++ b/Akash Kumar/q6.c @@ -0,0 +1,61 @@ +#include +int countSubStr(char str[]) +{ +int res = 0; // Initialize result + +// Pick a starting point +for (int i=0; str[i] !='\0'; i++) +{ + if (str[i] == '1') + { + // Search for all possible ending point + for (int j=i+1; str[j] !='\0'; j++) + if (str[j] == '1') + res++; + } +} +return res; +} + +// Driver program to test above function +int main() +{ +int n; +int i; +int a[10]; +char str[] = "01101"; + +printf("Enter no of Test cases:- "); +scanf("%d",&n); +for(i=0;i Date: Tue, 4 May 2021 23:05:12 +0530 Subject: [PATCH 094/110] Create q7.c --- Akash Kumar/q7.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Akash Kumar/q7.c diff --git a/Akash Kumar/q7.c b/Akash Kumar/q7.c new file mode 100644 index 000000000..c8c72dfde --- /dev/null +++ b/Akash Kumar/q7.c @@ -0,0 +1,42 @@ +#include +#include +int Number(char *str, char *Substring, int n, int k) +{ + int res=0; + for(int i=0;i<=n-k;i++) + { + int j; + for(j=0;j Date: Tue, 4 May 2021 23:05:38 +0530 Subject: [PATCH 095/110] Create q8.c --- Akash Kumar/q8.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Akash Kumar/q8.c diff --git a/Akash Kumar/q8.c b/Akash Kumar/q8.c new file mode 100644 index 000000000..d49f889bd --- /dev/null +++ b/Akash Kumar/q8.c @@ -0,0 +1,26 @@ +#include +int main() +{ + int i, n, sum=0; + printf("Enter no of elemets of array"); + scanf("%d",&n); + int arr[n]; + for(i=0;i Date: Tue, 4 May 2021 23:06:04 +0530 Subject: [PATCH 096/110] Create q9.c --- Akash Kumar/q9.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Akash Kumar/q9.c diff --git a/Akash Kumar/q9.c b/Akash Kumar/q9.c new file mode 100644 index 000000000..00c6cd912 --- /dev/null +++ b/Akash Kumar/q9.c @@ -0,0 +1,39 @@ +#include +#include +#include +int main() +{ + int n; + printf("Enter no of elements of array"); + scanf("%d", &n); + int arr[n]; + int i, x; + for (i = 0; i < n; i++) + { + printf("Enter the %dth element", i + 1); + scanf("%d", &arr[i]); + } + int A, B, C; + printf("Enter A , B and C"); + scanf("%d%d%d", &A, &B, &C); + int p, q, r; + int count = 0; + for (int i = 0; i < n - 2; i++) + { + for (int j = i + 1; j < n - 1; j++) + { + for (int k = j + 1; k < n; k++) + { + p = arr[i] - arr[j]; + q = arr[j] - arr[k]; + r = arr[i] - arr[k]; + if ((abs(p) <= A) && + (abs(q) <= B) && (abs(r) <= C)) + { + count = count + 1; + } + } + } + } + printf("the triple is %d", count); +} From 8fb9b4782e7c129658e01afe4a53b08c41aa60ae Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:06:28 +0530 Subject: [PATCH 097/110] Create q10.c --- Akash Kumar/q10.c | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Akash Kumar/q10.c diff --git a/Akash Kumar/q10.c b/Akash Kumar/q10.c new file mode 100644 index 000000000..1efa8e9e9 --- /dev/null +++ b/Akash Kumar/q10.c @@ -0,0 +1,11 @@ +#include +#if A== 1 + #define B 0 +#else + #define B 1 +#endif +int main() +{ + printf("%d", B); + return 0; +} From 3d0beb0341ff7b85ee794422ebd89754a7c2fef3 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:06:55 +0530 Subject: [PATCH 098/110] Create q11.c --- Akash Kumar/q11.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Akash Kumar/q11.c diff --git a/Akash Kumar/q11.c b/Akash Kumar/q11.c new file mode 100644 index 000000000..11ffea424 --- /dev/null +++ b/Akash Kumar/q11.c @@ -0,0 +1,72 @@ +#include +#include +#include +/*int CountTriplets(int arr[], int n, int A, int B, int C) +{ + int p, q, r; + int count = 0; + for(int i = 0; i < n - 2; i++) + { + for(int j=i+1; j < n - 1; j++) + { + for(int k=j+1; k < n; k++) + { + p=arr[i]-arr[j]; + printf("%d",p); + q=arr[j]-arr[k]; + printf("%d", q); + r=arr[i]-arr[k]; + printf("%d",r); + if ((p <= A) && + (q <= B) && (r <= C)) + { + count=count+1; + } + } + } + } + return count; +} +*/ +int main() +{ + int n; + printf("Enter no of elements of array"); + scanf("%d", &n); + int arr[n]; + int i, x; + for (i = 0; i < n; i++) + { + printf("Enter the %dth element", i + 1); + scanf("%d", &arr[i]); + } + int A, B, C; + printf("Enter A , B and C"); + scanf("%d%d%d", &A, &B, &C); + int p, q, r; + int count = 0; + for (int i = 0; i < n - 2; i++) + { + for (int j = i + 1; j < n - 1; j++) + { + for (int k = j + 1; k < n; k++) + { + p = arr[i] - arr[j]; + printf("%d\n", p); + q = arr[j] - arr[k]; + printf("%d\n", q); + r = arr[i] - arr[k]; + printf("%d\n", r); + if ((abs(p) <= A) && + (abs(q) <= B) && (abs(r) <= C)) + { + count = count + 1; + printf("count is %d\n", count); + } + } + } + } + //x = CountTriplets(arr[n], n, A, B, C); + // printf("the triple is %d", x); + printf("the triple is %d", count); +} From 04a602368fa08629cd342537d6c5da124ab67b36 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:07:20 +0530 Subject: [PATCH 099/110] Create q12.c --- Akash Kumar/q12.c | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Akash Kumar/q12.c diff --git a/Akash Kumar/q12.c b/Akash Kumar/q12.c new file mode 100644 index 000000000..76feb897f --- /dev/null +++ b/Akash Kumar/q12.c @@ -0,0 +1,11 @@ +#include +#define fun(x)(x*x-x) +int main() { + int x=y=z=8; + + printf("%d%d%d",x,y,z); + + + + return 0; +} From ca0fa02483181a7f5e8eca059e49ab2b866d6f72 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:08:52 +0530 Subject: [PATCH 100/110] Update q12.c --- Akash Kumar/q12.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Akash Kumar/q12.c b/Akash Kumar/q12.c index 76feb897f..2d37ce912 100644 --- a/Akash Kumar/q12.c +++ b/Akash Kumar/q12.c @@ -1,7 +1,10 @@ #include #define fun(x)(x*x-x) int main() { - int x=y=z=8; + int x,y,z; + x=8; + y=8; + z=8; printf("%d%d%d",x,y,z); From b043032083b2018e9812c741372a3fe080adaad8 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:09:34 +0530 Subject: [PATCH 101/110] Create q13.c --- Akash Kumar/q13.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Akash Kumar/q13.c diff --git a/Akash Kumar/q13.c b/Akash Kumar/q13.c new file mode 100644 index 000000000..e95009c3b --- /dev/null +++ b/Akash Kumar/q13.c @@ -0,0 +1,24 @@ +#include + +int main () { + int marks; + printf("enter your marks\n"); + scanf("%d", &marks); + if(marks>89 && marks<=100) + { + printf("Your grade is A"); + } + else if(marks>79 && marks<=90) { + printf("Your grade is B"); + } + else if(marks>69 && marks<=80) { + printf("Your grade is C"); + } + else if(marks>50 && marks<=70) { + printf("Your grade is D"); + } + else { + printf("Your grade is F"); + } + return 0; +} From 1770cb3d1c4d9e5ef8040d0fbd73f4682f5e91a6 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:11:41 +0530 Subject: [PATCH 102/110] Update q13.c --- Akash Kumar/q13.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/Akash Kumar/q13.c b/Akash Kumar/q13.c index e95009c3b..3c82e4c3d 100644 --- a/Akash Kumar/q13.c +++ b/Akash Kumar/q13.c @@ -1,24 +1,30 @@ #include - -int main () { - int marks; - printf("enter your marks\n"); - scanf("%d", &marks); - if(marks>89 && marks<=100) - { - printf("Your grade is A"); - } - else if(marks>79 && marks<=90) { - printf("Your grade is B"); - } - else if(marks>69 && marks<=80) { - printf("Your grade is C"); +int main () +{ + int a; + int b; + int c; + int d; + int greatest=0; + printf("ENTER 1ST NUMBER"); + scanf("%d", &a); + printf("ENTER 2nd NUMBER"); + scanf("%d", &b); + printf("ENTER 3rd NUMBER"); + scanf("%d", &c); + printf("ENTER 4th NUMBER"); + scanf("%d", &d); + if(a>>b) { + greatest=a; } - else if(marks>50 && marks<=70) { - printf("Your grade is D"); - } - else { - printf("Your grade is F"); + else + { + greatest=b; } + + + + printf("Greatest number is %d", greatest); + return 0; } From 5ed5b5a0e5e295f602c6d9c055dc26415640a08f Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:12:28 +0530 Subject: [PATCH 103/110] Create q14.c --- Akash Kumar/q14.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Akash Kumar/q14.c diff --git a/Akash Kumar/q14.c b/Akash Kumar/q14.c new file mode 100644 index 000000000..2faef4e2e --- /dev/null +++ b/Akash Kumar/q14.c @@ -0,0 +1,27 @@ +#include +int main() { + int year; + int leap_year=0; + printf("enter year"); + scanf("%d", &year); + + if(year%4==0) { + leap_year=leap_year + 1; + } + if(year%100==0) { + leap_year=leap_year-1; + } + if(year%400==0) { + leap_year=leap_year+1; + } + + if(leap_year==1){ + printf("%d is a leap year", year); + } + else + { + printf("%d is not a leap year", year); + } + +return 0; +} From 07b32bb7fd993ff4f60259dd9eefb726d8b32080 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:13:04 +0530 Subject: [PATCH 104/110] Create q15.c --- Akash Kumar/q15.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Akash Kumar/q15.c diff --git a/Akash Kumar/q15.c b/Akash Kumar/q15.c new file mode 100644 index 000000000..6814148e5 --- /dev/null +++ b/Akash Kumar/q15.c @@ -0,0 +1,15 @@ +#include +void main(){ +printf("ODD OR EVEN\n"); +int a; +printf("Enter a\n"); +scanf("%d", &a); +if (a%2==0) +{ + printf("%d is an Even number\n", a); +} +else +{ + printf("%d is an Odd number\n", a); +} +} From 300752a690cdfcdb9c089a44efef7015e4ca5720 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:15:44 +0530 Subject: [PATCH 105/110] Create q16.c --- Akash Kumar/q16.c | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Akash Kumar/q16.c diff --git a/Akash Kumar/q16.c b/Akash Kumar/q16.c new file mode 100644 index 000000000..08830dde9 --- /dev/null +++ b/Akash Kumar/q16.c @@ -0,0 +1,7 @@ +#include +int main() { + int a=5; + printf("value of address is %u\n", &a); + printf("value of a is %d", *(&a)); + return 0; +} From cdce484078e63774979293c9772a59495e307092 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:16:44 +0530 Subject: [PATCH 106/110] Create q17.c --- Akash Kumar/q17.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Akash Kumar/q17.c diff --git a/Akash Kumar/q17.c b/Akash Kumar/q17.c new file mode 100644 index 000000000..45418030b --- /dev/null +++ b/Akash Kumar/q17.c @@ -0,0 +1,13 @@ +#include +int vae(int a); +int main(){ + int i; + printf("the value of address is %u\n", &i); + vae(i); + printf("the value of address is %u\n", &i); + return 0; +} +int vae(int a) { +printf("the address of a is %u\n", &a); + +} From 25f95e50129f38514be00ba89578b8269d464780 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:17:09 +0530 Subject: [PATCH 107/110] Create q18.c --- Akash Kumar/q18.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Akash Kumar/q18.c diff --git a/Akash Kumar/q18.c b/Akash Kumar/q18.c new file mode 100644 index 000000000..4f052114d --- /dev/null +++ b/Akash Kumar/q18.c @@ -0,0 +1,29 @@ +#include + +#define MAX 10 + +int main() +{ + int i,j; + + for(i=0; i< MAX; i++) + { + for(j=0;j<=i;j++) + { + printf("*"); + } + printf("\n"); + } + + for(i=MAX-1; i>=1 ; i--) + { + + for(j=i;j>0;j--) + { + printf("*"); + } + printf("\n"); + } + + return 0; +} From 751aee395d37a4d6ed233ec52a62b4694935fd61 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:17:50 +0530 Subject: [PATCH 108/110] Create q19.c --- Akash Kumar/q19.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Akash Kumar/q19.c diff --git a/Akash Kumar/q19.c b/Akash Kumar/q19.c new file mode 100644 index 000000000..7ce8dfb8e --- /dev/null +++ b/Akash Kumar/q19.c @@ -0,0 +1,30 @@ +#include +int main() +{ +int N; //Number of * in the middle row +scanf("%d", &N); //Value of N is taken from test data + +int i,j,k,s=1; + for (i=1; i<=N; i++) { + for (k=s; k=1; i--) { + for (k=s; k>0; k--) { + printf(" "); + } + for (j=i; j>=1; j--) { + printf("*"); + } + s = s + 1; + printf("\n"); + } + +} From 25be325f5ba844f7ae19b0036924c309bcc65089 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:20:16 +0530 Subject: [PATCH 109/110] Create q20.c --- Akash Kumar/q20.c | 288 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 Akash Kumar/q20.c diff --git a/Akash Kumar/q20.c b/Akash Kumar/q20.c new file mode 100644 index 000000000..b1bbb9889 --- /dev/null +++ b/Akash Kumar/q20.c @@ -0,0 +1,288 @@ +#include + +int main(void) +{ + int num; + + printf("Enter a two-digit number: "); + scanf("%d", &num); + + printf("You have entered: "); + + switch (num) + { + case 10: + printf("ten"); + return 0; + case 11: + printf("eleven"); + return 0; + case 12: + printf("twelve"); + return 0; + case 13: + printf("thirteen"); + return 0; + case 14: + printf("fourteen"); + return 0; + case 15: + printf("fifteen"); + return 0; + case 16: + printf("sixteen"); + return 0; + case 17: + printf("seventeen"); + return 0; + case 18: + printf("eigthteen"); + return 0; + case 19: + printf("nineteen"); + return 0; + case 20: + printf("twenty"); + break; + case 21: + printf("Twenty-one"); + break; + case 22: + printf("Twenty-two"); + break; + case 23: + printf("Twenty-three"); + break; + case 24: + printf("Twenty-four"); + break; + case 25: + printf("Twenty-five"); + break; + case 26: + printf("Twenty-six"); + break; + case 27: + printf("Twenty-seven"); + break; + case 28: + printf("Twenty-eight"); + break; + case 29: + printf("Twenty-nine"); + break; + case 30: + printf("thirty"); + break; + case 31: + printf("Thirty-one"); + break; + case 32: + printf("Thirty-two"); + break; + case 33: + printf("Thirty-three"); + break; + case 34: + printf("Thirty-four"); + break; + case 35: + printf("Thirty-five"); + break; + case 36: + printf("Thirty-six"); + break; + case 37: + printf("Thirty-seven"); + break; + case 38: + printf("Thirty-eight"); + break; + case 39: + printf("Thirty-nine"); + break; + case 40: + printf("forty"); + break; + + case 41: + printf("Fourty-one"); + break; + case 42: + printf("Fourty-two"); + break; + case 43: + printf("Fourty-three"); + break; + case 44: + printf("Fourty-four"); + break; + case 45: + printf("Fourty-five"); + break; + case 46: + printf("Fourty-six"); + break; + case 47: + printf("Fourty-seven"); + break; + case 48: + printf("Fourty-eight"); + break; + case 49: + printf("Fourty-nine"); + break; + case 50: + printf("fifty"); + break; + case 51: + printf("Fifty-one"); + break; + case 52: + printf("Fifty-two"); + break; + case 53: + printf("Fifty-three"); + break; + case 54: + printf("Fifty-four"); + break; + case 55: + printf("Fifty-five"); + break; + case 56: + printf("Fifty-six"); + break; + case 57: + printf("Fifty-seven"); + break; + case 58: + printf("Fifty-eight"); + break; + case 60: + printf("sixty"); + break; + case 59: + printf("Fifty-nine"); + break; + case 61: + printf("Sixty-one"); + break; + case 62: + printf("Sixty-two"); + break; + case 63: + printf("Sixty-three"); + break; + case 64: + printf("Sixty-four"); + break; + case 65: + printf("Sixty-five"); + break; + case 66: + printf("Sixty-six"); + break; + case 67: + printf("Sixty-seven"); + break; + case 68: + printf("Sixty-eight"); + break; + case 69: + printf("Sixty-nine"); + break; + case 70: + printf("seventy"); + break; + case 71: + printf("Seventy-one"); + break; + case 72: + printf("Seventy-two"); + break; + case 73: + printf("Seventy-three"); + break; + case 74: + printf("Seventy-four"); + break; + case 75: + printf("Seventy-five"); + break; + case 76: + printf("Seventy-six"); + break; + case 77: + printf("Seventy-seven"); + break; + case 78: + printf("Seventy-eight"); + break; + case 79: + printf("Seventy-nine"); + break; + case 80: + printf("eighty"); + break; + case 81: + printf("Eighty-one"); + break; + case 82: + printf("Eighty-two"); + break; + case 83: + printf("Eighty-three"); + break; + case 84: + printf("Eighty-four"); + break; + case 85: + printf("Eighty-five"); + break; + case 86: + printf("Eighty-six"); + break; + case 87: + printf("Eighty-seven"); + break; + case 88: + printf("Eighty-eight"); + break; + case 89: + printf("Eighty-nine"); + break; + case 90: + printf("ninety"); + break; + case 91: + printf("Ninety-one"); + break; + case 92: + printf("Ninety-two"); + break; + case 93: + printf("Ninety-three"); + break; + case 94: + printf("Ninety-four"); + break; + case 95: + printf("Ninety-five"); + break; + case 96: + printf("Ninety-six"); + break; + case 97: + printf("Ninety-seven"); + break; + case 98: + printf("Ninety-eight"); + break; + case 99: + printf("Ninety-nine"); + break; + } + + return 0; +} From 1c746dea9d4f83405117551f101e34e6f2092969 Mon Sep 17 00:00:00 2001 From: akashkumar0987d <80807783+akashkumar0987d@users.noreply.github.com> Date: Tue, 4 May 2021 23:20:44 +0530 Subject: [PATCH 110/110] Create q21.c --- Akash Kumar/q21.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 Akash Kumar/q21.c diff --git a/Akash Kumar/q21.c b/Akash Kumar/q21.c new file mode 100644 index 000000000..ca8fa3f46 --- /dev/null +++ b/Akash Kumar/q21.c @@ -0,0 +1,123 @@ +#include + +int main(void) +{ + int num; + + printf("Enter a two-digit number: "); + scanf("%d", &num); + + printf("You have entered: "); + if (num < 20) + { + switch (num) + { + case 10: + printf("ten"); + return 0; + case 11: + printf("eleven"); + return 0; + case 12: + printf("twelve"); + return 0; + case 13: + printf("thirteen"); + return 0; + case 14: + printf("fourteen"); + return 0; + case 15: + printf("fifteen"); + return 0; + case 16: + printf("sixteen"); + return 0; + case 17: + printf("seventeen"); + return 0; + case 18: + printf("eigthteen"); + return 0; + case 19: + printf("nineteen"); + return 0; + } + } + else + { + switch (num / 10) + { + + case 2: + printf("twenty"); + break; + + case 3: + printf("thirty"); + break; + + case 4: + printf("forty"); + break; + + case 5: + printf("fifty"); + break; + + case 6: + printf("Sixty"); + break; + case 7: + printf("seventy"); + break; + + case 8: + printf("eighty"); + break; + + case 9: + printf("ninety"); + break; + } + switch (num % 10) + { + + case 1: + printf("-one"); + break; + case 2: + printf("-two"); + break; + + case 3: + printf("-three"); + break; + + case 4: + printf("-four"); + break; + + case 5: + printf("-five"); + break; + + case 6: + printf("-Six"); + break; + case 7: + printf("-seven"); + break; + + case 8: + printf("-eight"); + break; + + case 9: + printf("-nine"); + break; + } + } + + return 0; +}