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

Program 1

The document contains two C programs. The first program identifies strong numbers from user input by calculating the factorial of each digit and comparing the sum to the original number. The second program computes the sum of a series based on a user-defined value and number of terms using factorial calculations.

Uploaded by

padipaaaa3010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Program 1

The document contains two C programs. The first program identifies strong numbers from user input by calculating the factorial of each digit and comparing the sum to the original number. The second program computes the sum of a series based on a user-defined value and number of terms using factorial calculations.

Uploaded by

padipaaaa3010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Program 1

#include <stdio.h>

int fact(int r)

int mul=1;

for (int i = 1; i <=r; i++)

mul=mul*i;

return mul;

int main()

int arr[12],strong[12],not_strong[12],i,j=0,z=0;

for (i = 0; i < 12; i++)

printf("Enter Element %d: ",i+1);

scanf("%d",&arr[i]);

for (i = 0; i < 12; i++)

int k=arr[i];

int r,sum=0;

while (k!=0)

r=k%10;
int f=fact(r);

k=k/10;

sum+=f;

if(sum==arr[i])

strong[j]=arr[i];

j++;

else

not_strong[z]=arr[i];

z++;

printf("Strong Array: \n");

for (i = 0; i<j; i++)

printf("Element %d : %d\n",i+1,strong[i]);

printf("Not Strong Array: \n");

for (i = 0; i<z; i++)

printf("Element %d : %d\n",i+1,not_strong[i]);

return 0;
program 2
#include <stdio.h>

int main()

float x,s,t,num=1.00,fac=1.00;

int i,n,pr,y=2,m=1;

printf("Input the Value of x :");

scanf("%f",&x);

printf("Input the number of terms : ");

scanf("%d",&n);

s=1.00; t=1.00;

for (i=1;i<n;i++)
{

for(pr=1;pr<=y;pr++)

fac=fac*pr;

num=num*x;

m=m*(-1);

num=num*m;

t=num/fac;

s=s+t;

y=y+2;

num=1.00;

fac=1.00;

printf("\nthe sum = %f\nNumber of terms = %d\nvalue of x = %f\n",s,n,x);}

You might also like