ZOHO INTERVIEW QUESTION -7 (C PROGRAMMING)
QUESTION:
To output the given string for the given input which is an integer.
Input: 1
Output: A
Input: 26
Output: Z
Input : 27
Output: AA
Input: 28:
Output: AB
Input: 1000
Output: ALL
Input: 1
Output: A
Input: 26
Output: Z
Input : 27
Output: AA
Input: 28:
Output: AB
Input: 1000
Output: ALL
PROGRAM:
#include<stdio.h>
#include<string.h>
int main()
{
int a,i=0,j;
char b[100];
scanf("%d",&a);
while(a>0)
{
if((a%26)==0)
{
b[i]='Z';
a=a/26;
if(a==1)
a=0;
}
else
{
b[i]=((a%26)+64);
a=a/26;
}
i++;
}
for(j=i-1;j>=0;j--)
{
printf("%c",b[j]);
}
}
#include<string.h>
int main()
{
int a,i=0,j;
char b[100];
scanf("%d",&a);
while(a>0)
{
if((a%26)==0)
{
b[i]='Z';
a=a/26;
if(a==1)
a=0;
}
else
{
b[i]=((a%26)+64);
a=a/26;
}
i++;
}
for(j=i-1;j>=0;j--)
{
printf("%c",b[j]);
}
}
Wrong code, please stop post these wrong codes
ReplyDeleteI saw you posted many wrong codes without cross checking and compiling it, don't do that, you are just wasting others time
ReplyDeleteThanks for noticing... I have found the error and rectified it
Delete