Skip to content

Commit 601c9ff

Browse files
authored
Merge pull request Vishnu-M-E#2 from karthikjash/main
Day1
2 parents 6f27e00 + b80b2b4 commit 601c9ff

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

Day-1/issue1.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ int main()
88

99
for (int i = 0; i < rows; i++) {
1010

11-
for (int j = 0; j < 2 * (rows - i) - 1; j--) {
11+
for (int j = 0; j < 2 * (rows - i) - 1; j++) {
1212
printf(" ");
1313
}
1414

1515
for (int k = 0; k < 2 * i + 1; k++) {
16-
printf("");
16+
printf("*");
17+
printf(" ");
1718
}
18-
printf("*");
19-
printf("\t");
19+
printf("\n");
2020
}
2121

22-
printf("%d \n", rows);
2322

2423
return 0;
2524
}
@@ -29,4 +28,4 @@ int main()
2928
* * * * *
3029
* * * * * * *
3130
* * * * * * * * *
32-
*/
31+
*/

Day-1/issue3.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
//A program to find the factorial of 10
2+
//A program to find the factorial of 10
23

34
#include <stdio.h>
45

56
long factorial(int n) {
67

78
long result = 1;
89

9-
while (n--) {
10+
while (n>1) {
1011
printf("Result: %ld, n:%d\n", result, n);
1112
result *= n;
13+
n = n-1;
1214
}
1315

1416
return result;
@@ -17,4 +19,4 @@ long factorial(int n) {
1719
int main() {
1820

1921
printf("%ld\n", factorial(10));
20-
}
22+
}

Day-1/issue5.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ int main()
1111

1212
printf("Fibonacci Series: ");
1313

14-
for (i = 1; i <= numTerms; ++i)
14+
for (i = 1; i <= numTerms; i++)
1515
{
1616
printf("%d, ", t1);
1717
nextTerm = t1 + t2;
18-
t1 = nextTerm;
19-
t2 = t1;
18+
t1 = t2;
19+
t2 = nextTerm;
2020
}
2121

2222
return 0;
23-
}
23+
}

Day-1/issue6.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
even = {x: x+2 for x in range(0, 10)}
2-
odd = {x: x+2 for x in range(1, 10)}
1+
even = {x: 2*x for x in range(1, 6)}
2+
odd = {x: 2*x+1 for x in range(0, 5)}
33

44
sum_odd, sum_even = 0, 0
55

66
for i in even.keys():
7-
sum_even += even[i]
8-
7+
sum_even += even[i]
8+
for j in odd.keys():
9+
sum_odd += odd[j]
910

1011
sum = sum_odd + sum_even
1112

1213
print("Sum of the first 10 natural numbers is: ", sum)
1314
print(even)
14-
print(odd)
15+
print(odd)

Day-1/program

15.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)