C# Program to find whether the Number is Palindrome or not
using System; namespace NumberPalindrome { class Program { static void Main(string[] args) { int num, rem, sum = 0, temp; //clrscr(); Console.WriteLine("\n >>>> To Find a Number is Palindrome or not <<<< "); Console.Write("\n Enter a number: "); num = Convert.ToInt32(Console.ReadLine()); temp = num; while (num>0) { rem = num % 10; //for getting remainder by dividing with 10 num = num / 10; //for getting quotient by dividing with 10 sum = sum * 10 + rem; /*multiplying the sum with 10 and adding remainder*/ } Console.WriteLine("\n The Reversed Number is: {0} \n", sum); if (temp == sum) //checking whether the reversed number is equal to entered number { Console.WriteLine("\n Number is Palindrome \n\n"); } else { Console.WriteLine("\n Number is not a palindrome \n\n"); } Console.ReadLine(); } } }
Output 1:
Output 2:
For C Program: C Program To Find The Number Palindrome or Not
// program to check if a string/number is a palindrome or not.
ReplyDeleteusing System;
class Palindrome
{
public static bool CheckPal(Char[] MyStr)
{
int first = 0;
int Last;
Last = MyStr.Length - 1;//using Length method to check the total number of characters in the array.
while (first < Last)//executes the loop till the last character of the array.
{
if (MyStr[first] == MyStr[Last])// checking if arrays from both the ends are equal.
{
first++;
Last--;
}
else
{
return false;
}
}
return true;
}
public static void Main(string[] args)
{
char[] str = new char[10];
Console.WriteLine(" Enter a string/number to check if it is a palindrome \n");
str = Console.ReadLine().ToCharArray();// accepting string and converting it to char array.
Console.WriteLine(CheckPal(str));
Console.ReadLine();
}
}
int pal = 1001;
ReplyDeletechar[] number = pal.ToString().ToCharArray();
int iteration = number.Count() / 2;
int endChar = number.Count() - 1;
bool isPalindromic = true;
for (int i = 0; i < iteration; i++)
{
if (number[i] == number[endChar])
{
}
else
{
isPalindromic = false;
}
if (!isPalindromic)
{
break;
}
endChar--;
}
Console.WriteLine(isPalindromic.ToString());
Console.ReadLine();
int reminder, number, sum = 0;
ReplyDeleteConsole.WriteLine();
number = int.Parse(Console.ReadLine());
for (int i = number; i >0; i=i/10)
{
reminder = i % 10;
sum = sum * 10 + reminder;
}
if (sum == number)
{
Console.WriteLine("Armstrong number ");
}
else
{
Console.WriteLine("not a Armstrong number ");
}
Console.ReadLine();
Great Explanation..Very good Example..
ReplyDeleteOnline CSharp
Training
C Sharp Training
Online C# Training from India
C Sharp Training in Chennai
C# Training
Online Dot Net Training
.net online Training
ASP NET Training
This comment has been removed by the author.
ReplyDeleteThanks for the post!
ReplyDeleteC# Programming
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteusing System.Collections.Generic;
ReplyDeletepublic static LinkedList WagonLinkList = new LinkedList();
This comment has been removed by the author.
ReplyDeleteusing System;
ReplyDeletepublic class Program
{
public static bool TruePalindrome(string word)
{
word=word.ToLower();
bool result=false;
string NewWord="";
for(int start=(word.Length-1);start>=0;start--)
{
NewWord=NewWord+word[start];
}
if(word==NewWord)
{
return true;
}
return false;
}
public static void Main(string[] args)
{
Console.WriteLine(Palindrome.IsPalindrome("RAVAR"));
}
}
public static Tuple TowTotal(IList list, int sum)
ReplyDelete{
for(int firstIndex=0;firstIndex<list.Count-1;firstIndex++)
{
for(int secondIndex=firstIndex+1;secondIndex<list.Count;secondIndex++)
{
if(list[firstIndex]+list[secondIndex]==sum)
{
return Tuple.Create(firstIndex,secondIndex);
}
}
}
return null;
int Capacity { get; set; }
ReplyDeleteList Items = new List();
Safe(int capacity)
{
this.Capacity = capacity;
}
int getCapacity()
{
return Capacity;
}
List getItems()
{
return Items;
}
void AddItem(string item)
{
if (Items.Count < Capacity)
{
Items.Add(item);
Console.WriteLine(Items.Count + "" + "/" + "" + Capacity);
}
else
{
throw new Exception("Error Occured safe is full ");
}
}
string getDescription()
{
if (Items.Count >= Capacity)
return "Safe is full";
else
return "Safe: " + Items.Count + "/" + Capacity;
}
if(Password.Length>=12)
ReplyDelete{
int UpperCount = 0;
int LowerCount = 0;
int DigitCount = 0;
//for(int start=0;start= 'a' && c <= 'z')
{
LowerCount++;
}
if (c >= 'A' && c <= 'Z')
{
UpperCount++;
}
if (c >= '0' && c <= '9')
{
DigitCount++;
}
}
if (UpperCount > 0 && LowerCount > 0 && DigitCount > 0)
{
return true;
}
}
return false;
using System.Collections.Generic;
ReplyDeletepublic static LinkedList WagonLinkList = new LinkedList();
public static int FrogWays(int n)
ReplyDelete{
int firstnumber = 0, secondnumber = 1, result = 0;
if (n == 1) return 1;
if (n == 2) return 2;
for (int i = 2; i <= n + 1; i++)
{
result = firstnumber + secondnumber;
firstnumber = secondnumber;
secondnumber = result;
}
return result;
}
public static int MyCountNumbers(int[] sortedArray, int lessThan)
ReplyDelete{
int Icount=0;
foreach(int val in sortedArray)
{
if(val<lessThan)
{
Icount++;
}
else
{
return Icount;
}
}
return Icount;
}
This comment has been removed by the author.
ReplyDeletepublic static int BestLongRunning(string str)
ReplyDelete{
int bestIndex = 0, bestScore = 0, currIndex = 0;
for (var i = 0; i < str.Length; ++i)
{
if (str[i] == str[currIndex])
{
if (bestScore < i - currIndex)
{
bestIndex = currIndex;
bestScore = i - currIndex;
}
}
else
{
currIndex = i;
}
}
return bestIndex;
static int BoxNoIs(int products, int availableLargeBoxes, int availableSmallBoxes)
ReplyDelete{
if (products < 5)
return products;
if ((products - (5 * availableLargeBoxes + availableSmallBoxes)) > 0)
return -1;
int rl = products / 5;
if (rl > availableLargeBoxes)
rl = availableLargeBoxes;
return rl + (products - 5 * rl);
}
class StacksBank
ReplyDelete{
public int capacity { get; set; }
public Stack Items = new Stack();
Stacks(int MyCapacity)
{
capacity = MyCapacity;
}
int getCapacity()
{
return capacity;
}
List getItems()
{
return Items.ToList();
}
void addItem(string item)
{
if (Items.Count >= capacity)
{
throw new Exception ("OverFlow");
}
Items.Push(item);
}
string getDescription()
{
if (Items.Count >= capacity)
return "Safe is full";
else
return "Safe: " + Items.Count + "/" + capacity;
}
using System;
ReplyDeletenamespace ChickenEgg
{
public interface IBird
{
Egg Lay();
}
public class Egg
{
private readonly Func _createBird;
private bool _hatched;
public Egg(Func createBird)
{
_createBird = createBird;
}
public IBird Hatch()
{
if (_hatched) throw new InvalidOperationException("Egg already hatched.");
_hatched = true;
return _createBird();
}
}
public class Chicken : IBird
{
public Egg Lay()
{
var egg = new Egg(() => new Chicken());
return egg;
}
}
public class Program
{
public static void Main(string[] args)
{
var chicken1 = new Chicken();
var egg = chicken1.Lay();
var childChicken = egg.Hatch();
var childChicken2 = egg.Hatch();
}
}
}
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteData Science training in marathahalli
Data Science training in btm
Data Science training in rajaji nagar
Data Science training in chennai
Data Science training in electronic city
Data Science training in USA
Data science training in pune
Data science training in kalyan nagar
It is nice article to improve my knowledge.thank you for sharing useful info
ReplyDeleteweb programming tutorial
welookups
This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
ReplyDeletepython training in rajajinagar
Python training in btm
Python training in usa
Python training in marathahalli
Python training in pune
Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
ReplyDeleteDevops training in sholinganallur
Well you use a hard way for publishing, you could find much easier one!
ReplyDeleteBlueprism training in tambaram
Blueprism training in annanagar
Awesome! Education is the extreme motivation that open the new doors of data and material. So we always need to study around the things and the new part of educations with that we are not mindful.
ReplyDeleteangularjs-Training in sholinganallur
angularjs-Training in velachery
angularjs Training in bangalore
angularjs Training in bangalore
angularjs Training in btm
Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
ReplyDeleteAWS Interview Questions And Answers
AWS Training in Bangalore | Amazon Web Services Training in Bangalore
AWS Training in Pune | Best Amazon Web Services Training in Pune
Amazon Web Services Training in Pune | Best AWS Training in Pune
AWS Online Training | Online AWS Certification Course - Gangboard
Great blog, keep posting and update more information.
ReplyDeleteSelenium Training in Chennai
Selenium Course in Chennai
iOS Course in Chennai
Digital Marketing Training in Chennai
J2EE Training in Chennai
DOT NET Course in Chennai
DOT NET Training Institute in Chennai
Big Data Training in Chennai
Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
ReplyDeletedevops online training
aws online training
data science with python online training
data science online training
rpa online training
thanks for sharing this information
ReplyDeleteaws training in bangalore
Amazon web services training in bangalore
best AWS Training institute in Bangalore
aws certification course in bangalore
devops training in bangalore
devops training institutes in bangalore
devops certification course in bangalore
data science training in bangalore
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteIt’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read.
ReplyDeleteData science Course Training in Chennai |Best Data Science Training Institute in Chennai
RPA Course Training in Chennai |Best RPA Training Institute in Chennai
AWS Course Training in Chennai |Best AWS Training Institute in Chennai
superb....
ReplyDeleteinplant training in chennai for it
namibia web hosting
norway web hosting
rwanda web hosting
spain hosting
turkey web hosting
venezuela hosting
vietnam shared web hosting
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
ReplyDeleteBig Data Hadoop Training In Chennai | Big Data Hadoop Training In anna nagar | Big Data Hadoop Training In omr | Big Data Hadoop Training In porur | Big Data Hadoop Training In tambaram | Big Data Hadoop Training In velachery
ReplyDeleteThe strategy you have posted on this technology helped me to get into the next level and had lot of information in it. The angular js programming language is very popular which are most widely used.
Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery
Mumbai University B.Com 2nd, 4th, 6th Sem Result 2020
ReplyDeleteOsmania University B.Com 2nd, 4th, 6th Sem Result 2020
Utkal University B.Com 2nd, 4th, 6th Sem Result 2020
You’d outstanding guidelines there. I did a search about the field and identified that very likely the majority will agree with your web page.
Hey, Wow all the posts are very informative for the people who visit this site. Good work! We also have a Website. Please feel free to visit our site. Thank you for sharing.Well written article Thank You Sharing.DevOps Training in Chennai
ReplyDeleteDevOps Course in Chennai