0% found this document useful (0 votes)
44 views4 pages

Those Numbers Which Sum of Its Digits To Power of Number of Its Digits Is Equal To That Number Are Known As Armstrong Numbers

The document contains definitions and examples of various terms in computer science and programming including: 1. Perfect numbers and Armstrong numbers 2. Floyd's triangle which is a right angled triangle using natural numbers 3. Pascal's triangle where each number is the sum of the numbers directly above it 4. ASCII values of characters 5. Writing a program that outputs its own source code 6. Adding two numbers without using the plus operator 7. Extracting digits from an integer

Uploaded by

Rahul Kr
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views4 pages

Those Numbers Which Sum of Its Digits To Power of Number of Its Digits Is Equal To That Number Are Known As Armstrong Numbers

The document contains definitions and examples of various terms in computer science and programming including: 1. Perfect numbers and Armstrong numbers 2. Floyd's triangle which is a right angled triangle using natural numbers 3. Pascal's triangle where each number is the sum of the numbers directly above it 4. ASCII values of characters 5. Writing a program that outputs its own source code 6. Adding two numbers without using the plus operator 7. Extracting digits from an integer

Uploaded by

Rahul Kr
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

FOR INTERVIEW: Some Terms: 1.

Perfect Number: Perfect number is a positive number which sum of all positive
divisors excluding that number is equal to that number.

Those numbers which sum of its digits to power of number of its digits is equal to that number are known as Armstrong numbers.
2.

while(num!=0){ r=num%10; num=num/10; sum=sum+(r*r*r); } 3. A number is called strong number if sum of the factorial of its digit is equal to number itself. 4. while(num){ r=num%10; num=num/10; sum=sum*10+r; } number palindrome 5.string palindrome: for(i=strlen(str)-1,j=0;i>=0;i--,j++) rev[j]=str[i]; rev[j]='\0'; if(strcmp(rev,str)) 6. printf("FLOYD'S TRIANGLE\n\n"); for(i=1;i<=r;i++){ for(j=1;j<=i;j++,k++) printf(" %d",k); printf("\n")

Floyd's triangle is a right angled-triangle using the natural numbers. Examples of floyd's triangle. 7. Pascal triangle: betten is sum of bottom 2.
long fact(int); int main(){ int line,i,j; printf("Enter the no. of lines: "); scanf("%d",&line); for(i=0;i<line;i++){ for(j=0;j<line-i-1;j++) printf(" "); for(j=0;j<=i;j++) printf("%ld ",fact(i)/(fact(j)*fact(i-j))); printf("\n"); } return 0; } long fact(int num){ long f=1; int i=1; while(i<=num){ f=f*i; i++; } return f; }

8. ASCII value of character 0: 48

ASCII value of character A: 65 ASCII value of character a: 97


9. void main(){

if(printf("Hello world")){ } } How do you write a program which produces its own source code as its output in c language?
10.
#include<stdio.h> int main(){ FILE *fp; char c; fp = fopen(__FILE__,"r");

do{ c= getc(fp); putchar(c); } while(c!=EOF); fclose(fp); return 0; }

11. How to add two numbers without using the plus operator in c
#include<stdio.h> int main(){ int a,b; int sum; printf("Enter any two integers: "); scanf("%d%d",&a,&b); //sum = a - (-b); sum = a - ~b -1; printf("Sum of two integers: %d",sum); return 0; } 12. generic root :

#include <stdio.h> int main(){ int num,x; printf("Enter any number: "); scanf("%d",&num); printf("Generic root: %d",(x=num%9)?x:9); return 0; } 13. // string to int in c with inbuilt ??/ 14. swap two integers without using extra variables : a=a+b; b=a-b; a=a-b;

15. Extract

digits from integer in c language

#include<stdio.h> int main(){ int num,temp,factor=1; printf("Enter a number: "); scanf("%d",&num); temp=num; while(temp){ temp=temp/10; factor = factor*10; } printf("Each digits of given number are: "); while(factor>1){ factor = factor/10; printf("%d ",num/factor); num = num % factor; } return 0; }

You might also like