From e041480d8d69cd15df991a42665913552eb173e7 Mon Sep 17 00:00:00 2001 From: Keshav Kumar <71294563+keshavkumar9431@users.noreply.github.com> Date: Sat, 27 Nov 2021 02:55:21 +0530 Subject: [PATCH 01/10] Create "Hello World!" in C --- "C/\"Hello World!\" in C" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "C/\"Hello World!\" in C" diff --git "a/C/\"Hello World!\" in C" "b/C/\"Hello World!\" in C" new file mode 100644 index 0000000..226091c --- /dev/null +++ "b/C/\"Hello World!\" in C" @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +int main() +{ + + char s[100]; + scanf("Welcome to C programming.", &s); + printf("Hello, World!\n%s"); + printf("Welcome to C programming."); + + + /* Enter your code here. Read input from STDIN. Print output to STDOUT */ + return 0; +} From 83322edc3ff99129b5c7392e7f0be482e3b34d9d Mon Sep 17 00:00:00 2001 From: Keshav Kumar <71294563+keshavkumar9431@users.noreply.github.com> Date: Sat, 27 Nov 2021 02:56:05 +0530 Subject: [PATCH 02/10] Create Playing With Characters --- C/Playing With Characters | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 C/Playing With Characters diff --git a/C/Playing With Characters b/C/Playing With Characters new file mode 100644 index 0000000..5f633ac --- /dev/null +++ b/C/Playing With Characters @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +int main() +{ + char ch; + scanf("%c", &ch); + printf("%c\n", ch); + + char s[10]; + scanf("%s", s); + printf("%s\n", s); + + char sen[100]; + scanf("\n"); + scanf("%[^\n]%*c", sen); + printf("%s\n", sen); + + /* Enter your code here. Read input from STDIN. Print output to STDOUT */ + return 0; +} From b022183c60604d020cea7ccc8f83af754e102b48 Mon Sep 17 00:00:00 2001 From: Keshav Kumar <71294563+keshavkumar9431@users.noreply.github.com> Date: Sat, 27 Nov 2021 02:56:48 +0530 Subject: [PATCH 03/10] Create Sum and Difference of Two Numbers --- C/Sum and Difference of Two Numbers | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 C/Sum and Difference of Two Numbers diff --git a/C/Sum and Difference of Two Numbers b/C/Sum and Difference of Two Numbers new file mode 100644 index 0000000..d2dd3a8 --- /dev/null +++ b/C/Sum and Difference of Two Numbers @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +int main() +{ + int a,b,c,d; + scanf("%d", &a); + scanf("%d", &b); + c=a+b; + d=a-b; + printf("%d", c); + printf(" %d\n", d); + + float e,f,g,h; + scanf("%f", &e); + scanf("%f", &f); + g=e+f; + h=e-f; + printf("%.1f", g); + printf(" %.1f", h); + + + return 0; +} From aefde29d52cdaf7ab6084dd2c3a01a328b43b819 Mon Sep 17 00:00:00 2001 From: Keshav Kumar <71294563+keshavkumar9431@users.noreply.github.com> Date: Sat, 27 Nov 2021 02:57:54 +0530 Subject: [PATCH 04/10] Create Functions in C --- C/Functions in C | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 C/Functions in C diff --git a/C/Functions in C b/C/Functions in C new file mode 100644 index 0000000..8a9f270 --- /dev/null +++ b/C/Functions in C @@ -0,0 +1,20 @@ +#include +int max(int a, int b, int c, int d){ + int max=a; + if(b>max) + max=b; + if(c>max) + max=c; + if(d>max) + max=d; + return max; +} + +int main() { + int a, b, c, d; + scanf("%d %d %d %d", &a, &b, &c, &d); + int ans = max(a, b, c, d); + printf("%d", ans); + + return 0; +} From 40c8e52dd0f1b86879e73c60e75e2d5766eb0e74 Mon Sep 17 00:00:00 2001 From: Keshav Kumar <71294563+keshavkumar9431@users.noreply.github.com> Date: Sat, 27 Nov 2021 02:58:39 +0530 Subject: [PATCH 05/10] Create Pointers in C --- C/Pointers in C | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 C/Pointers in C diff --git a/C/Pointers in C b/C/Pointers in C new file mode 100644 index 0000000..09be3e6 --- /dev/null +++ b/C/Pointers in C @@ -0,0 +1,26 @@ +#include + +void update(int *a,int *b) { + int sum, sub; + sum=*a + *b; + printf("%d\n",sum); + + if(*a>*b){ + sub=*a-*b; + } + else{ + sub=*b-*a; + } + printf("%d", sub); +} + +int main() { + int a, b; + int *pa = &a, *pb = &b; + + scanf("%d %d", &a, &b); + update(pa, pb); + // printf("%d\n%d", a, b); + + return 0; +} From 3c20f4d15c35c8dae12f294f96a667987dc94a84 Mon Sep 17 00:00:00 2001 From: Keshav Kumar <71294563+keshavkumar9431@users.noreply.github.com> Date: Sat, 27 Nov 2021 02:59:57 +0530 Subject: [PATCH 06/10] Create Conditional Statements in C --- C/Conditional Statements in C | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 C/Conditional Statements in C diff --git a/C/Conditional Statements in C b/C/Conditional Statements in C new file mode 100644 index 0000000..a5219fe --- /dev/null +++ b/C/Conditional Statements in C @@ -0,0 +1,16 @@ +#include +static const char *strings[] = {"one","two","three","four","five", + "six","seven","eight","nine"}; +int main() +{ + int n = 0; + if (scanf("%d",&n) < 1) + return 1; + + if (n >= 1 && n <= 9) + printf("%s",strings[n-1]); + else + printf("Greater than 9"); + + return 0; +} From 46129905ab108707567808a83c0310434d8b9171 Mon Sep 17 00:00:00 2001 From: Keshav Kumar <71294563+keshavkumar9431@users.noreply.github.com> Date: Sat, 27 Nov 2021 03:00:33 +0530 Subject: [PATCH 07/10] Create For Loop in C --- C/For Loop in C | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 C/For Loop in C diff --git a/C/For Loop in C b/C/For Loop in C new file mode 100644 index 0000000..dddb060 --- /dev/null +++ b/C/For Loop in C @@ -0,0 +1,58 @@ +#include +#include +#include +#include + + + +int main() +{ + int a, b, i; + scanf("%d\n%d", &a, &b); + for(i=a; i<=b; i++){ + if(i==0){ + printf("Zero\n"); + } + else if(i==1){ + printf("one\n"); + } + else if(i==2){ + printf("two\n"); + } + else if(i==3){ + printf("three\n"); + } + else if(i==4){ + printf("four\n"); + } + else if(i==5){ + printf("five\n"); + } + else if(i==6){ + printf("six\n"); + } + else if(i==7){ + printf("seven\n"); + } + else if(i==8){ + printf("eight\n"); + } + else if(i==9){ + printf("nine\n"); + } + else if(i>9){ + if(i%2==0){ + printf("even\n"); + } + else{ + printf("odd\n"); + } + } + + } + + + + return 0; +} + From 53c7849bac1809fcb84eba207542e20a3450fc46 Mon Sep 17 00:00:00 2001 From: Keshav Kumar <71294563+keshavkumar9431@users.noreply.github.com> Date: Sat, 27 Nov 2021 03:01:22 +0530 Subject: [PATCH 08/10] Create Sum of Digits of a Five Digit Number --- C/Sum of Digits of a Five Digit Number | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 C/Sum of Digits of a Five Digit Number diff --git a/C/Sum of Digits of a Five Digit Number b/C/Sum of Digits of a Five Digit Number new file mode 100644 index 0000000..4af6ca8 --- /dev/null +++ b/C/Sum of Digits of a Five Digit Number @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +int main() { + + int n, sum; + scanf("%d", &n); + while(n>0){ + sum+= n%10; + n= n/10; + } + printf("%d", sum); + + return 0; +} From 4d3c71bb51b9eedc02f9c440b696c6f76f3c172a Mon Sep 17 00:00:00 2001 From: Keshav Kumar <71294563+keshavkumar9431@users.noreply.github.com> Date: Sat, 27 Nov 2021 03:02:08 +0530 Subject: [PATCH 09/10] Create Bitwise Operators --- C/Bitwise Operators | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 C/Bitwise Operators diff --git a/C/Bitwise Operators b/C/Bitwise Operators new file mode 100644 index 0000000..5d82fb8 --- /dev/null +++ b/C/Bitwise Operators @@ -0,0 +1,41 @@ +#include +#include +#include +#include +//Complete the following function. + + +void calculate_the_maximum(int n, int k) { + int a,b,c; + int d=0, e=0, f=0; + for(int i=1;i<=n; i++){ + for(int j=i+1; j<=n; j++){ + a=i|j; + b=i&j; + c=i^j; + if(a Date: Sat, 27 Nov 2021 03:02:53 +0530 Subject: [PATCH 10/10] Create Printing Pattern Using Loops --- C/Printing Pattern Using Loops | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 C/Printing Pattern Using Loops diff --git a/C/Printing Pattern Using Loops b/C/Printing Pattern Using Loops new file mode 100644 index 0000000..219c9a9 --- /dev/null +++ b/C/Printing Pattern Using Loops @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +int main() +{ + + int n; + scanf("%d", &n); + int size=n*2-1; + for(int i=0; i