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 |
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']
Write a procedure to implement highlight as a blinking operation
main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }
What is data _null_? ,Explain with code when u need to use it in data step programming ?
void main () { int x = 10; printf ("x = %d, y = %d", x,--x++); } a. 10, 10 b. 10, 9 c. 10, 11 d. none of the above
typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }
What are the files which are automatically opened when a C file is executed?
void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above
main() { if ((1||0) && (0||1)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above
main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }
main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }