Posts

Showing posts with the label C programming

40. Program to Display Armstrong Number Between Two Intervals

39. Program to Check Armstrong Number

38. Program to Display Prime Numbers Between Two Intervals

37. Program to Check Whether a Number is Prime or Not

36. Program to Check Whether a Number is Palindrome or Not

35. Program to Calculate the Power of a Number

34. Program to print Reverse a Number

33. Program to Count Number of Digits of an Integer

32. Program to Display Character from A to Z Using Loop

void main() { char ch; clrscr(); for(ch='A';ch<='Z';ch++) printf("%c\t",ch); getch(); }

31. Program to Find LCM of two Numbers

30. Program to Find GCD of two Numbers

void main() { int x,y,m,i; clrscr(); printf("Enter any two number: "); scanf("%d%d",&x,&y); if(x>y) m=y; else m=x; for(i=m;i>=1;i--) { if(x%i==0&&y%i==0) { printf("\nGCD of two number is : %d",i) ; break; } } getch(); }

29. Program to Display Fibonacci Series

28. Program to Generate Multiplication Table

void main() { int i,j;clrscr(); printf("\n\n\n\nEnter a number for Multiplication Table\t"); scanf("%d",&j); printf("\n\n\n\nMultiplication table is\n"); for(i=1;i<=10;i++) { printf("\t|%d * %d| = %d\t|\n",j,i,j*i); } getch(); }

27. Program to Find Factorial of a Number

void main() { int n, count; int factorial=1; clrscr(); printf("Enter an integer: "); scanf("%d",&n); if ( n< 0) { printf("Error!!! Factorial of negative number doesn't exist."); } else { for(count=1;count<=n;++count) { factorial*=count; } printf("Factorial = %lu",factorial); } getch(); }

26. Program to Calculate Sum of Natural Numbers from 25 to 39

25. Program to Check Whether a Character is an Alphabet or not

24. Program to Check Whether a Number is Positive or Negative

void main() { float c; clrscr(); printf("Enter a number: "); scanf("%f",&c); if (c<=0) { if (c==0) printf("You entered zero."); else printf("%.2f is negative.",c); } else { printf("%.2f is positive.",c); } getch(); }

23. Program to Check Leap Year

void main() { int year; clrscr(); printf("\n\t Enter a year to check if it is a leap year"); scanf("%d", &year); if ( year%400 == 0) printf("\n\t%d is a leap year", year); else if ( year%100 == 0) printf("\n\t %d is not a leap year", year); else if ( year%4 == 0 ) printf("\n\t %d is a leap year", year); else printf("\n\t %d is not a leap year", year); getch(); }

22. program to Find all Roots of a Quadratic equation

21. Program to Find the Largest Number Among Three Numbers