1 / 6

#include< stdio.h > #include< conio.h > #include< math.h > void main() { unsigned long int a;

ADDING DIGITS. #include< stdio.h > #include< conio.h > #include< math.h > void main() { unsigned long int a; int i,b,sum =0; clrscr (); printf ("enter a no. to add digits of"); scanf ("% lu",&a ); while(a>0) { b=a%10; sum= sum+b ; a=a/10; }

sharis
Télécharger la présentation

#include< stdio.h > #include< conio.h > #include< math.h > void main() { unsigned long int a;

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ADDING DIGITS #include<stdio.h> #include<conio.h> #include<math.h> void main() { unsigned long int a; inti,b,sum=0; clrscr(); printf("enter a no. to adddigits of"); scanf("%lu",&a); while(a>0) { b=a%10; sum=sum+b; a=a/10; } printf(“sumof digits is %d",sum); getch(); }

  2. #include<stdio.h> #include<conio.h> #include<math.h> void main() { unsigned long inta,rev=0; int b; clrscr(); printf("enter a no. to reverse"); scanf("%lu",&a); while(a>0) { b=a%10; rev=rev*10+b; a=a/10; } printf("no. in reverse order%lu",rev); getch(); } REVERSE DIGITS TO CHECK WHETHER NO. IS SAME BEFORE & AFTER REVERSING: Declare org,org=a,at last if(org==rev) printf(“same”); else printf(“different”);

  3. #include<stdio.h> #include<conio.h> #include<math.h> void main() { long int fact=1; int a; clrscr(); printf("enter a no. to find factorial of"); scanf("%d",&a); fact=a; for(a=a-1;a>1;a--) { fact=fact*a; } printf("factorial of no. is %ld",fact); getch(); } FACTORIAL

  4. #include<stdio.h> #include<conio.h> #include<math.h> void main() { inta,i; clrscr(); printf("enter a no. to check prime or not"); scanf("%d",&a); for(i=2;i<a;i++) { if((a%i)==0) { printf("number is not prime"); goto end; } } printf("number is prime"); end: getch(); } PRIME NUMBER

  5. #include<stdio.h> #include<conio.h> #include<math.h> void main() { int a=0,b=1,sum,i,n; clrscr(); printf("enter a no. of terms in fibbonacci series"); scanf("%d",&n); printf("%d\t%d",a,b); for(i=0;i<=n-2;i++) { sum=a+b; printf("\t%d",sum); a=b; b=sum; } getch(); } FIBBONACCI SERIES

More Related