ADDING
Download
1 / 6

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


  • 220 Views
  • Uploaded on

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; }

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' #include< stdio.h > #include< conio.h > #include< math.h > void main() { unsigned long int a;' - sharis


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

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();

}


#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”);


#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


#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


#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


ad