TO PRINT ALPHABET PYRAMID
ABCDEFGGFEDCBA
ABCDEFFEDCBA
ABCDEEDCBA
ABCDDCBA
ABCCBA
ABAB
A
#include
#incldue
int main( )
{
int r,c,askey,sp;
clrscr( );
for( r=7; r>=1; r-- )
{
for(sp=6; sp>=r; sp--)
printf(" "); //2 spaces
askey=65;
for(c=1; c<=r; c++ )
printf("%2c", askey++ );
for(c=r-1; c>=1; c-- )
printf("%2c", --askey);
printf("\n");
}
getch();
return 0;
}
by BRAMHA VARDHAN
#include
main()
{
int number, temp, digit1, digit2, digit3;
printf("Printing all Armstrong numbers between 1 and 500:\n\n");
number = 001;
while (number <= 500)
{
digit1 = number - ((number / 10) * 10);
digit2 = (number / 10) - ((number / 100) * 10);
digit3 = (number / 100) - ((number / 1000) * 10);
temp = (digit1*digit1*digit1) + (digit2*digit2*digit2) + (digit3*digit3*digit3);
if (temp == number)
{
printf("\nAmstrong Number:%d", temp);
}
number++;
}
}
#include<stdio.h> #include<conio.h> #include<math.h> int armstrong(int num) { int i,c=0,arm=0; int ar[100]; for(i=0;i<100;i++) { ar[i]=0; } while(num>0) { ar[c]=num%10; c++; num/=10; } for(i=1;i<c;i++) { arm+=pow(ar[i],3); } return arm; } void main() { clrscr(); int n,a=0; printf("\n Enter the number: "); scanf("%d",&n); a=armstrong(n); printf("\n The number %d is",n); if(n==a) printf(" armstrong number"); else printf(" not an armstrong number"); getch(); }
This site is not for home-works, it is for questions.
import java.io.*; public class Jerry { public static void main(String as[]) throws IOException { int k=Integer.parseInt(as[0]); int n=k; int d=0,s=0; while(n>0) { d=n%10; s=s+(d*d*d); n=n/10; } if(k==s) System.out.println("Armstrong number"); else System.out.println("not Armstrong number"); } }
* * * * * * * * * * write the c++ program and show me brifily?
By using those two functions in your code.
i cant write
Write a program to convert a 2-digit BCD number into hexadecimal
Functions are very important in C++, as you can't write the simplest program to print hello without using a function. Overall you can say that function are building blocks of a C++ program. Functions can also be defined by the programmer to reduce program size.
trytytytytytytytytrf 6 bcvvtgujhy6
One.int main (void) { return 0; }
import java.io.*; class Armstrong { public static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter a number"); int a=Integer.parseInt(in.readLine()); int n1=a,rev=0,d=0; while(a!=0) { d=a%10; rev=rev+d*d*d; a=a/10; } if(rev==n1) System.out.println("It is a armstrong number "); else System.out.println("It is not a armstrong number "); } }
Classes are well organised functions in java which help discriminate between two different functions.
You can use Java's built-in functions to write a code that will find multilingual languages.
WRITE A PROGRAM TO CONVERT A 2-DIGIT bcd NUMBER INTO HEXADECIMAL