In this program, we are going to share a C program to display upper triangular matrix. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a C program to display upper triangular matrix with the output.
We have designed this program for beginners for learning purpose. Copy below c program and execute it with c compiler to see the output of the program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include <stdio.h> int main() { long binary1, binary2; int i = 0, remainder = 0, sum[20]; printf("Enter the first binary number: "); scanf("%ld", &binary1); printf("Enter the second binary number: "); scanf("%ld", &binary2); while (binary1 != 0 || binary2 != 0) { sum[i++] =(binary1 % 10 + binary2 % 10 + remainder) % 2; remainder =(binary1 % 10 + binary2 % 10 + remainder) / 2; binary1 = binary1 / 10; binary2 = binary2 / 10; } if (remainder != 0) sum[i++] = remainder; --i; printf("Sum of two binary numbers: "); while (i >= 0) printf("%d", sum[i--]); return 0; } |
Enter the first binary number: 10
Enter the second binary number: 101
Sum of two binary numbers: 111
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.