Write a program to receive an integer and find it's octal
equivalent.
How can i do with using while loop.
Answers were Sorted based on User's Feedback
Answer / mithun shrivastav
#include<stdio.h>
void main()
{
int n,sum = 0,rev = 0;
print("\nEnter an Integer No. : ");
scanf("%d", &n);
while(n>0)
{
sum = sum * 10 + n%8;
n = n/8;
}
while(sum > 0)
{
rev = rev*10 + sum%10;
sum = sum/10;
}
printf("Octal Equivalent = ", rev);
getch();
}
| Is This Answer Correct ? | 19 Yes | 16 No |
write a origram swaoing valu without 3rd variable
pls anyone can help me to write a code to print the values in words for any value.Example:1034 to print as "one thousand and thirty four only"
#include<stdio.h> main() { register i=5; char j[]= "hello"; printf("%s %d",j,i); }
#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }
main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }
main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }
void main() { int c; c=printf("Hello world"); printf("\n%d",c); }
main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024
main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }
#define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\ __FILE__,__LINE__), abort()) void main() { int i = 10; if(i==0) assert(i < 100); else printf("This statement becomes else for if in assert macro"); }
hello sir,is there any function in C that can calculate number of digits in an int type variable,suppose:int a=123; 3 digits in a.what ll b answer?
How to palindrom string in c language?