+ 1
how to write code in c# for this program:-
Given an input number keep the prime digits as it is and the remaining digit in given input number should be replaced with next number(add +1 to the digit).
2 Respostas
0
store digits in array and run a for loop with if statement
0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int n=int.Parse(Console.ReadLine());
int[] a=new int[n];
int no,rem;
no=n;
int i=0,j,c=0,h=0,k=0;
while(no>0)
{
rem=no%10;
if(rem>0)
{
for(j=1;j<=rem;j++)
{
if(rem%j==0)
{
c++;
}
}
while(c!=0)
{ i=1;
if(c!=2)
{
rem=rem+1;
a[k]=rem*i;
}
else
{
a[k]=rem*i;
}
i=i*10;
h++;
}
}
no=no/10;
}
for(k=h-1;k>=0;k--)
{
Console.WriteLine(a[k]);
}
}
}
}
I have written this code.but it is not working