Skip to content

Commit 3cbd211

Browse files
committed
Column Name From a Given String
Problem From The Easy Section.
1 parent ec477f3 commit 3cbd211

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//GeeksForGeeks Problem : Column name from a given column number(Easy)
2+
//Author : Piyush
3+
#include<stdio.h>
4+
int main()
5+
{
6+
int t,no,l,i,p;
7+
char str[20],str1[]={'Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y'};
8+
scanf("%d",&t);
9+
while(t--)
10+
{
11+
l=0;
12+
i=0;
13+
scanf("%d",&no);
14+
while(no)
15+
{
16+
p=no%26;
17+
str[i]=str1[p];
18+
no/=26;
19+
l++;
20+
i++;
21+
}
22+
str[l]='\0';
23+
i=0;
24+
for(i=l-1;i>=0;i--)
25+
{
26+
printf("%c",str[i]);
27+
}
28+
printf("\n");
29+
}
30+
return 0;
31+
}

0 commit comments

Comments
 (0)