commit e0449243e49564ef986a806669bc76b7fdb6ded3
parent 3daef3921999e64e12c06e6fdf17724ea2bc1d92
Author: Amit Dutta <amitdutta4255@gmail.com>
Date: Wed, 8 Oct 2025 12:46:55 +0530
new 31 with array
Diffstat:
1 file changed, 32 insertions(+), 0 deletions(-)
diff --git a/letusc/luc032.c b/letusc/luc032.c
@@ -0,0 +1,31 @@
+/* Write a program to recieve an integer and find its octal equivalent.
+(Hint : To obtain octal equivalent of an integer, Divide it continuously
+by 8 till dividend does not become zero, then write the remainders
+obtained in reverse derection.) */
+/* Author - Amit Dutta, Date - 8th OCT, 2025 */
+/* Let Us C, Chap- 5, Page - 87, Qn No.: B(e) */
+
+// using array
+
+#include <stdio.h>
+int main()
+{
+ int octal[20], decimal, index = 0, temp, rem;
+ printf("Enter the decimal number : ");
+ scanf("%d", &decimal);
+ temp = decimal;
+ while (temp != 0)
+ {
+ rem = temp % 8;
+ temp = temp / 8;
+ octal[index] = rem;
+ index++;
+ }
+ printf("\nDeciaml %d to octal : ", decimal);
+ while ((index - 1) >= 0)
+ {
+ printf("%d", octal[index - 1]);
+ index--;
+ }
+ return 0;
+}+
\ No newline at end of file