Skip to content

Commit

Permalink
added others folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Surajkumarsaw1 committed Mar 28, 2023
1 parent f0e5d5f commit e6ebe47
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
*.exe
*.out
others
*.out
4 changes: 2 additions & 2 deletions assignment-5/d/19.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ int main() {

case 2:
float sum = 0;
for (float i =1; i<=n; i+=1){
sum = sum + ((i*2)-1)/(i*2);
for (int i = 1; i<=n; i++){
sum = sum + (((float) i*2 )-1)/ (float) ( i*2 );
}
printf("Sum of above series upto %d terms is %f\n",n,sum);

Expand Down
45 changes: 45 additions & 0 deletions assignment-5/d/20.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Using a switch statement, write a menu driven program to:
(a) Generate and display the first 10 terms of the Fibonacci series
0, 1, 1, 2, 3, 5
The first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.
(b) Find the sum of the digits of an integer that is input.
Sample Input: 15390
Sample Output: Sum of the digits = 18
For an incorrect choice, an appropriate error message should be displayed.
*/

#include <stdio.h>

int main() {
int op, n;



printf("Options : \n\t");
printf("1. Generate and display the first 10 terms of the Fibonacci series. \n\t");
printf("2. ind the sum of the digits of an integer that is input.\n\n\t");
printf("Enter option : ");
scanf("%d",&op);

printf("Enter a number : ");
scanf("%d",&n);

switch (op)
{
case 1:


break;

case 2:


break;

default:
printf("Enter a valid option.\n");
break;
}
return 0;
}
19 changes: 19 additions & 0 deletions others/classes/2023-03-24/1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>

int main() {
for (int i =1; i<=5;i++){
for (int j = 1;j<=i; j++){
printf("%d ",j);
}
printf("\n");
}
return 0;
}

/*
1
12
123
1234
12345
*/
20 changes: 20 additions & 0 deletions others/classes/2023-03-24/2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>

int main() {
int init = 'A', end = init+4;
for (int i = init; i<=end;i++){
for (int j = init;j<=i; j++){
printf("%c ",j);
}
printf("\n");
}
return 0;
}

/*
A
A B
A B C
A B C D
A B C D E
*/
22 changes: 22 additions & 0 deletions others/classes/2023-03-24/3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>

int main() {
for (int i =1; i<=5;i++){
for (int k = 5-i; k>0; k--){
printf(" ");
}
for (int j = 1;j<=i; j++){
printf("%d ",j);
}
printf("\n");
}
return 0;
}

/*
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
*/
24 changes: 24 additions & 0 deletions others/classes/2023-03-24/4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>

int main() {

for (int i =1; i<=5;i++){
for (int k = 5-i; k>0; k--){
printf(" ");
}
int c = 'A';
for (int j = 1;j<=i; j++){
printf("%c ",c++);
}
printf("\n");
}
return 0;
}

/*
A
A B
A B C
A B C D
A B C D E
*/
11 changes: 11 additions & 0 deletions others/classes/2023-03-28/typecasing.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdio.h>

int main() {
int a;
a = 9/4;
printf("a = %d\n",a);

float b;
b = (float) 9 / 5;
printf("b = %f\n",b);
}
18 changes: 18 additions & 0 deletions others/python/bitwise.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def decimalToBinary(n):
return bin(n).replace("0b", "")

def binaryToDecimal(n):
return int(n,2)

a = 13
b = 4
print(a, "=",decimalToBinary(a))
print(b,"=",decimalToBinary(b))

print( decimalToBinary (a & b), "=", (a & b))
print( decimalToBinary ( a | b), "=", (a | b))
print( decimalToBinary ( a ^ b), "=", (a ^ b))
print( decimalToBinary ( a << b), "=", (a << b))
print( decimalToBinary ( a >> b), "=", (a >> b) )
print( decimalToBinary ( ~a), "=", (~a))

0 comments on commit e6ebe47

Please sign in to comment.