Find palindrome number in C++
#include
#include
using namespace std;
int main()
{
int palindrome, reverse=0;
cout<<"Enter number:
";
cin>>palindrome;
int num=0,key=palindrome;
for(int i=1;palindrome!=0;i++)
{
num=palindrome%10;
palindrome=palindrome/10;
reverse=num+(reverse*10);
}
if(reverse==key)
{
cout<
}
else
{
cout<
}
return 0;
}
Find Armstrong number in c++ code with logic explanation
and code dry run
#include
#include
using namespace std;
int main()
{
int armstrong=0,num=0,result=0,check;
cout<<"Enter
Number to find it is an Armstrong number?";
cin>>num;
check=num;
for(int i=1;num!=0;i++)
{
armstrong=num%10;
num=num/10;
armstrong=armstrong*armstrong*armstrong;
result=result+armstrong;
}
if(result==check)
{
cout<
}
else{
cout<
}
return 0;
}
Print
a right angle triangle using for loop
#include
#include
using namespace std;
int main()
{
for(int i=0;i<=5;i++)
{
for(int
j=0;j<=i;j++)
{
cout<
}
cout<
}
return
0;
}
No comments:
Post a Comment