-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0e5d5f
commit e6ebe47
Showing
9 changed files
with
162 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
*.exe | ||
*.out | ||
others | ||
*.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
|