WINIT Software interview question

1.Write a program to convert decimal number to binary, octal, hexadecimal number. 2.Pattern printing program.

Interview Answers

Anonymous

6 July 2018

#include #include void conversion(int num, int base) { int remainder = num % base; if(num == 0) { return; } conversion(num / base, base); if(remainder < 10) { printf("%d", remainder); } else { printf("%c", remainder - 10 + 'A' ); } } int main() { int num, choice; printf("\nEnter a Positive Decimal Number:\t"); scanf("%d", &num); while(1) { printf("\n1. Decimal To Binary Conversion"); printf("\n2. Decimal To Octal Conversion"); printf("\n3. Decimal To Hexadecimal Conversion"); printf("\n4. Quit"); printf("\nEnter Your Option:\t"); scanf("%d", &choice); switch(choice) { case 1: printf("\nBinary Value:\t"); conversion(num, 2); break; case 2: printf("\nOctal Value:\t"); conversion(num, 8); break; case 3: printf("\nHexadecimal Value:\t"); conversion(num, 16); break; case 4: exit(0); default: printf("Enter a correct input\n"); } } printf("\n"); return 0; }

1

Anonymous

21 June 2016

I think they didn't changed the question paper since 10 years, management dudes please change the paper at least as you cannot change the rules. Worst ever working culture. request you to not to join.

3