Q5A - i++; } else if (a==3) { s[j]='C'; p[j]=i; j++; i++; }...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<conio.h> #include<string.h> void main() { int n,y,x,a,k,i=0,j=0; int t[30],p[30]; char s[30]; clrscr(); printf("Enter the no"); scanf("%d",&n); printf("\n press 1 for binary"); printf("\n press 2 for octal"); printf("\n press 3 for hexadecimal"); scanf("%d",&y); x=n; switch(y) { case 1:{while(x>0) { t[i]=x%2; x=x/2; i++; } break; } case 2:{while(x>0) { t[i]=x%8; x=x/8; i++; } break; } case 3:{while(x>0) { if((x%16)<10) { t[i]=x%16; i++; } else { a=(x%16)-9; if (a==1) { s[j]='A'; p[j]=i; j++; i++; } else if (a==2) { s[j]='B'; p[j]=i; j++;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: i++; } else if (a==3) { s[j]='C'; p[j]=i; j++; i++; } else if (a==4) { s[j]='D'; p[j]=i; j++; i++; } else if (a==5) { s[j]='E'; p[j]=i; j++; i++; } else if (a==6) { s[j]='F'; p[j]=i; j++; i++; } } x=x/16; } break;} default :{printf("Invalid input");} } i--; j--; if(y==1||y==2) { while(i>=0) { printf("%d",t[i]); i--; } } else if(y==3) { while(i>=0) { for(k=j;k>=0;k--) { if(p[k]==i) { printf("%c",s[k]); i--; } else { printf("%d",t[i]); i--; } } } } getch(); }...
View Full Document

This note was uploaded on 10/25/2010 for the course CMPN SEM1 taught by Professor Thakur during the Fall '06 term at University of Mumbai.

Page1 / 3

Q5A - i++; } else if (a==3) { s[j]='C'; p[j]=i; j++; i++; }...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online