Sunny n=input() rev=[] for i in str(n): rev.append(i) reverse_final=rev[::-1] for i in range(len(reverse_final)): print(reverse_final[i],end=””) Log in to Reply
Raman // Online C compiler to run C program online #include int main() { char s[100],p[100]; int i=0,j,count=0; scanf(“%s”,s); while(s[i]!=’\0′){ count++; i++; } j=0; while((count-1)>=0){ p[j]=s[count-1]; count–; j++; } j++; p[j]=’\0′; printf(“%s”,p); return 0; } Log in to Reply
rohan #include int main() { int i; char n[10],temp[10];//ramsi gets(n); int l=strlen(n);//5 for(i=0;i<l;++i) { temp[i]=n[l-i-1]; } printf("%s\n%s",n,temp); } Log in to Reply
Pogakula #python3 def rev(s): final=” for i in range(-1,-len(s)-1,-1): final+=s[i] return final num=str(input()) print(rev(num)) Log in to Reply
Richik another way using stack def revs(n): stack=[] stri=”” for i in n: stack.append(i) for i in range(0,len(n)): stri+=(stack.pop()) for i in stri: print(i,end=””) revs(input()) Log in to Reply
Sadique Gametor #include int main() { char a[100]; scanf(“%[^\n]%*c”,a); int i,l=0; for(i=0;a[i]!=’\0′;i++) { l++; } for(i=l;i>=0;i–) { printf(“%c”,a[i]); } return 0; } Log in to Reply
Promit #include int main() { char a[100],ch; int l,i; gets(a); for(l=0;a[l];l++); for(i=0;i<l/2;i++) { ch=a[i]; a[i]=a[l-1-i]; a[l-1-i]=ch; } puts(a); return 0; } Log in to Reply
Shivam Garg public class reverse { public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String inp=br.readLine(); for(int i=inp.length()-1;i>=0;i–) { System.out.print(“”+inp.charAt(i)); } } } Log in to Reply
clash of clan import java.util.Scanner; public class revno { public static void main(String args[]) { int i,j,n,sum=0,k; Scanner sc=new Scanner(System.in); System.out.println(“Enter the no”); n=sc.nextInt(); while(n!=0) { k=n%10; sum=sum*10+k; n=n/10; //System.out.println(sum); } System.out.println(sum); } } Log in to Reply
n=input()
rev=[]
for i in str(n):
rev.append(i)
reverse_final=rev[::-1]
for i in range(len(reverse_final)):
print(reverse_final[i],end=””)
// Online C compiler to run C program online
#include
int main() {
char s[100],p[100];
int i=0,j,count=0;
scanf(“%s”,s);
while(s[i]!=’\0′){
count++;
i++;
}
j=0;
while((count-1)>=0){
p[j]=s[count-1];
count–;
j++;
}
j++;
p[j]=’\0′;
printf(“%s”,p);
return 0;
}
#include
int main()
{
int i;
char n[10],temp[10];//ramsi
gets(n);
int l=strlen(n);//5
for(i=0;i<l;++i)
{
temp[i]=n[l-i-1];
}
printf("%s\n%s",n,temp);
}
#python3
def rev(s):
final=”
for i in range(-1,-len(s)-1,-1):
final+=s[i]
return final
num=str(input())
print(rev(num))
another way using stack
def revs(n):
stack=[]
stri=””
for i in n:
stack.append(i)
for i in range(0,len(n)):
stri+=(stack.pop())
for i in stri:
print(i,end=””)
revs(input())
python 3
def revstr(n):
print(n[::-1])
revstr(input())
#include
int main()
{
char a[100];
scanf(“%[^\n]%*c”,a);
int i,l=0;
for(i=0;a[i]!=’\0′;i++)
{
l++;
}
for(i=l;i>=0;i–)
{
printf(“%c”,a[i]);
}
return 0;
}
Thanks for contributing your code Sadique
#include
int main()
{
char a[100],ch;
int l,i;
gets(a);
for(l=0;a[l];l++);
for(i=0;i<l/2;i++)
{
ch=a[i];
a[i]=a[l-1-i];
a[l-1-i]=ch;
}
puts(a);
return 0;
}
#python
n=int(input())
x=0
while(n>0):
a=n%10
x=x*10+a
n=n//10
print(x)
no java #only python
n=int(input())
print(str(n)[::-1])
public class reverse {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String inp=br.readLine();
for(int i=inp.length()-1;i>=0;i–)
{
System.out.print(“”+inp.charAt(i));
}
}
}
import java.util.Scanner;
public class revno
{
public static void main(String args[])
{
int i,j,n,sum=0,k;
Scanner sc=new Scanner(System.in);
System.out.println(“Enter the no”);
n=sc.nextInt();
while(n!=0)
{
k=n%10;
sum=sum*10+k;
n=n/10;
//System.out.println(sum);
}
System.out.println(sum);
}
}
You dont used i,j then why intialize ?