The document contains code to calculate the sum of the digits of the factorial of a given number. It initializes an array to store the digits, calculates the factorial iteratively by multiplying by numbers from 1 to the given number, stores the digits in the array, prints out the factorial and calculates the sum of its digits.
These problems are so common that you will find in any C learning curriculum. Either in your college or in any IT institute.
I have provided solutions to these problems as well.
Happy learning...
These problems are so common that you will find in any C learning curriculum. Either in your college or in any IT institute.
I have provided solutions to these problems as well.
Happy learning...
This document contains some programs of C using Data structures, like Stack, LinkedList, queue, Fibonacci series, addition and multiplication of two matrices,etc.
Ex.1 Write a program to print the following pattern
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Ex.2 Write a program to find bigger of three integers.
Ex.3 Write a program to calculate GCD between two numbers.
Ex.4 Write a program to find transpose of matrix.
Ex.5 Write a program which deletes an element from an array & display all other elements.
Ex.6 Write a program to calculate XA+YB where A & B are matrix & X=2, Y=3.
Ex.7 Write a program to calculate the total amount of money in the piggy bank, given that coins of Rs.10, Rs.5, Rs.2, RS.1.
& many more.....
Let us C (by yashvant Kanetkar) chapter 3 SolutionHazrat Bilal
All rights reserved. No part of this slide
may be reproduced, stored in a retrieval
system, or transmitted, in any form or by
any means, without the prior permission.
Magick Ovens bakery is started in Coimbatore on the busy streets of -------to satisfy our customers with the most delicious mouth-watering pastries. Magick ovens established itself with its uniquely designed mouth watering tasty pastries. We offer many flavors in pastries such as ‘chocolate’, ‘butterscotch’, ‘pineapple’, ‘Strawberry’ and many more with real flavors. We genuinely admit a point that Covai love the soft, silky, and delicious fresh cream layered pastries. We actually have a fan fall of customers who visits daily for our freshly baked variety of Breads, customized cakes, pastries, etc...
Magic Ovens pastry chefs use a combination of culinary ability and creativity in baking, decoration, and flavoring with ingredients. We spend lot of time in baking to get the exact texture, color and taste. Not only the baking part, we given separate attention for our presentation too. All our products are tasteful and definitely will win your heart with its appearance. We have good inventors in our team too… We are giving quality time for our innovators to give their best. We are so proud that our customers love our innovation and creativity ......
This document contains some programs of C using Data structures, like Stack, LinkedList, queue, Fibonacci series, addition and multiplication of two matrices,etc.
Ex.1 Write a program to print the following pattern
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Ex.2 Write a program to find bigger of three integers.
Ex.3 Write a program to calculate GCD between two numbers.
Ex.4 Write a program to find transpose of matrix.
Ex.5 Write a program which deletes an element from an array & display all other elements.
Ex.6 Write a program to calculate XA+YB where A & B are matrix & X=2, Y=3.
Ex.7 Write a program to calculate the total amount of money in the piggy bank, given that coins of Rs.10, Rs.5, Rs.2, RS.1.
& many more.....
Let us C (by yashvant Kanetkar) chapter 3 SolutionHazrat Bilal
All rights reserved. No part of this slide
may be reproduced, stored in a retrieval
system, or transmitted, in any form or by
any means, without the prior permission.
Magick Ovens bakery is started in Coimbatore on the busy streets of -------to satisfy our customers with the most delicious mouth-watering pastries. Magick ovens established itself with its uniquely designed mouth watering tasty pastries. We offer many flavors in pastries such as ‘chocolate’, ‘butterscotch’, ‘pineapple’, ‘Strawberry’ and many more with real flavors. We genuinely admit a point that Covai love the soft, silky, and delicious fresh cream layered pastries. We actually have a fan fall of customers who visits daily for our freshly baked variety of Breads, customized cakes, pastries, etc...
Magic Ovens pastry chefs use a combination of culinary ability and creativity in baking, decoration, and flavoring with ingredients. We spend lot of time in baking to get the exact texture, color and taste. Not only the baking part, we given separate attention for our presentation too. All our products are tasteful and definitely will win your heart with its appearance. We have good inventors in our team too… We are giving quality time for our innovators to give their best. We are so proud that our customers love our innovation and creativity ......
i am akash kolamkar ,in my city amravati maharashtra india ,, in my city amravati a biggest bridge structure is going to construct so i have an idea to make it useful for others,,, in this report i will explain all concept with detailed drawing presentation ,, because i am engineer of project with college student if want soft copy of that file with report also so, u can mail me at akashkolamkar@gmail.com
Here are the questions on Optics for CBSE Class-12 Students. These questions are important for the board exam. Practice these questions before your exam.
Ensayo 5 semestre de ingeniería comunicación no vervalMARQUEZA ROBLES
El proceso interpretativo del significado de los comportamientos no verbales está contextualizado y teñidos de posiciones teóricas-ideales que los profesionales mantienen del proceso comunicativo didáctico.
Se constata una muy escasa conciencia e irreflexibilidad del papel del mensaje no verbal en la enseñanza.
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
programs
1. #include<stdio.h>
void main()
{
int A[200]={0,1};
int i,j,k,h,n=2,s=0,m;
clrscr();
printf("Put a number for sum of the digits of its factorial.n");
scanf("%d",&m);
for(i=2;i<=m;i++)
{
h=0;
for(j=n-1;j>=0;j--)
{
k=A[j]*i+h;
A[j+2]=k%10;
h=k/10;
}
A[1]=h%10;
A[0]=h/10;
n=n+2;
}
printf("nnn");
for(i=0;i<2*m;i++)
s=s+A[i];
printf("The sum of the digits is %d",s);
getch();
}
SUM OF FACTORIAL DIGITS
1
2. #include<stdio.h>
void main()
{
int A[400]={1,0,2,4};
int i,j,k,h,n=4,s=0,m=100;
clrscr();
for(i=2;i<=m;i++)
{
h=0;
for(j=n-1;j>=0;j--)
{
k=A[j]*1024+h;
A[j+4]=k%10;
h=k/10;
}
A[3]=h%10;
h=h/10;
A[2]=h%10;
h=h/10;
A[1]=h%10;
A[0]=h/10;
n=n+4;
}
printf("nnn");
for(i=0;i<4*m;i++)
s=s+A[i];
printf("The sum of the digits is %d",s);
getch();
}
POWER DIGIT SUM
2
3. #include<stdio.h>
void main()
{
int i=0,j,p,temp,A[10]={0,1,2,3,4,5,6,7,8,9};
long int f,k=1,M=1000000;
long int fact(int);
clrscr();
while((k!=0)&&(i<9))
{
f=fact(9-i);
p=M/f;
k=M%f;
M=k;
if(p>0)
{
if(k==0)
p=p-1;
temp=A[p+i];
for(j=p+i;j>i;j--)
A[j]=A[j-1];
A[i]=temp;
}
i++;
}
printf("nnThe required number is:t");
for(j=0;j<i;j++)
printf("%d",A[j]);
for(j=9;j>=i;j--)
printf("%d",A[j]);
getch();
}
long int fact(int m)
{
long int r=1;
if(m==0)
return(r);
else
return(m*fact(m-1));
}
LEXICOGRAPHIC PERMUTATIONS
3
4. #include<stdio.h>
void main()
{
int n,m,i;
long int s=0;
int d(int);
clrscr();
printf("Input an upper bound.n");
scanf("%d",&n);
for(i=12;i<=n;i++)
{
m=d(i);
if((m>i)&&(i==d(m)))
{
if(m>n)
m=0;
s=s+m+i;
}
}
printf("nnThe sum is :%ld.",s);
getch();
}
int d(int a)
{
int r=0,j;
for(j=1;j<a;j++)
{
if(a%j==0)
r=r+j;
}
return(r);
}
AMICABLE NUMBERS
4
5. #include<stdio.h>
void main()
{
int A[200]={0,1};
int i,j,k,h,n=2,s=0,m;
clrscr();
printf("Put a number for sum of the digits of its factorial.n");
scanf("%d",&m);
for(i=2;i<=m;i++)
{
h=0;
for(j=n-1;j>=0;j--)
{
k=A[j]*i+h;
A[j+2]=k%10;
h=k/10;
}
A[1]=h%10;
A[0]=h/10;
n=n+2;
}
printf("nnn");
i=0;
while(1)
{
if(A[i]!=0)
break;
i++;
}
printf("nnThe factorial of %d is :nn",m);
for(j=i;j<2*m;j++)
{
printf("%d",A[j]);
s=s+A[j];
}
printf("nnThe number of digits is %d.",2*m-i);
printf("nnThe sum of the digits is %d",s);
getch();
}
SUM OF FACTORIAL DIGITS
5
6. Put a number for sum of the digits of its factorial.
100
The factorial of 100 is :
9332621544394415268169923885626670049071596826438162146859296389521759999322991
5608941463976156518286253697920827223758251185210916864000000000000000000000000
The number of digits is 158.
The sum of the digits is 648
Put a number for sum of the digits of its factorial.
20
The factorial of 20 is :
2432902008176640000
The number of digits is 19.
The sum of the digits is 54
Put a number for sum of the digits of its factorial.
10
The factorial of 10 is :
3628800
The number of digits is 7.
The sum of the digits is 27
OUTPUT-1
OUTPUT-2
OUTPUT-3
6
9. Input the power.
1000
The number 2 raised to 1000 is :
107150860718626732094842504906000181056140481170553360744375038837035105112493612249
319837881569585812759467291755314682518714528569231404359845775746985748039345677748
242309854210746050623711418779541821530464749835819412673987675591655439460770629145
71196477686542167660429831652624386837205668069376
The number of digits is 302.
The sum of the digits is 1366
Input the power.
20
The number 2 raised to 20 is :
1048576
The number of digits is 7.
The sum of the digits is 31
Input the power.
5
The number 2 raised to 5 is :
32
The number of digits is 2.
The sum of the digits is 5
OUTPUT-1
OUTPUT-2
OUTPUT-3
9
10. #include<stdio.h>
void main()
{
int i=0,j,p,temp,A[10]={0,1,2,3,4,5,6,7,8,9};
long int f,k=1,M,q;
long int fact(int);
clrscr();
printf("nnInput the lexicographic ordinal status. ");
scanf("%ld",&M);
printf("nnInput the number of digits using. ");
scanf("%d",&q);
f=fact(q);
if(M>f)
printf("nnThere are only %ld numbers in the list.",f);
else
{
while((k!=0)&&(i<q-1))
{
f=fact(q-i-1);
p=M/f;
k=M%f;
M=k;
if(p>0)
{
if(k==0)
p=p-1;
temp=A[p+i];
for(j=p+i;j>i;j--)
A[j]=A[j-1];
A[i]=temp;
}
i++;
}
printf("nnThe required number is:t");
for(j=0;j<i;j++)
printf("%d",A[j]);
for(j=q-1;j>=i;j--)
printf("%d",A[j]);
}
getch();
}
long int fact(int m)
{
long int r=1;
if(m==0)
return(r);
else
return(m*fact(m-1));
}
LEXICOGRAPHIC PERMUTATIONS
10
11. Input the lexicographic ordinal status.
1000000
Input the number of digits using.
10
The required number is: 2783915460
Input the lexicographic ordinal status.
5
Input the number of digits using.
3
The required number is: 201
Input the lexicographic ordinal status.
4000000
Input the number of digits using.
10
There are only 3628800 numbers in the list.
OUTPUT-1
OUTPUT-2
OUTPUT-3
11
12. #include<stdio.h>
void main()
{
int n,m,i;
long int s=0;
int d(int);
clrscr();
printf("Input an upper bound.n");
scanf("%d",&n);
printf("nnThe amicable pairs are :nn");
for(i=12;i<=n;i++)
{
m=d(i);
if((m>i)&&(i==d(m)))
{
printf("%dt%dnn",i,m);
if(m>n)
m=0;
s=s+m+i;
}
}
printf("nnThe sum of the amicable numbers below %d is :%ld.",n,s);
getch();
}
int d(int a)
{
int r=0,j;
for(j=1;j<a;j++)
{
if(a%j==0)
r=r+j;
}
return(r);
}
AMICABLE NUMBERS
12
13. Input an upper bound.
10000
The amicable pairs are :
220 284
1184 1210
2620 2924
5020 5564
6232 6368
The sum of the amicable numbers below 10000 is :31626.
Input an upper bound.
250
The amicable pairs are :
220 284
The sum of the amicable numbers below 250 is :220.
Input an upper bound.
500
The amicable pairs are :
220 284
The sum of the amicable numbers below 500 is :504.
OUTPUT-1
OUTPUT-2
OUTPUT-3
13
14. #include<stdio.h>
#include<math.h>
int m=1;
void main()
{
long int p,q;
int i,j,k,n,r=1,A[5000]={1},s=0;
long int pro(int);
clrscr();
printf("Input a number for the sum of its factorial digits.nn");
scanf("%d",&n);
while(m<=n)
{
p=pro(n);
q=0;
for(k=0;k<r;k++)
{
q=A[k]*p+q;
A[k]=q%10;
q=q/10;
}
while(q!=0)
{
A[k]=q%10;
q=q/10;
k++;
}
r=k;
}
printf("nnThe factorial of %d is :nn",n);
for(i=r-1;i>=0;i--)
{
printf("%d",A[i]);
s=s+A[i];
}
printf("nnThe number of digits is %d.nn",r);
printf("The sum of the digits is %d.",s);
getch();
}
long int pro(int a)
{
long int l=1,b;
b=pow(2,26);
while((l<=b/m)&&(m<=a))
{
l=l*m;
m++;
}
return(l);
}
SUM OF FACTORIAL DIGITS
14
15. #include<stdio.h>
#include<math.h>
void main()
{
long int p,q;
int i,j=0,k,l,m,n=1,A[310]={1},s=0;
clrscr();
printf("Input the power.n");
scanf("%d",&m);
l=m/27;
p=pow(2,27);
for(i=0;i<2;i++)
{
while(j<l)
{
q=0;
for(k=0;k<n;k++)
{
q=A[k]*p+q;
A[k]=q%10;
q=q/10;
}
while(q!=0)
{
A[k]=q%10;
q=q/10;
k++;
}
n=k;
j++;
}
j--;
p=pow(2,m%27);
}
printf("The number 2 raised to %d is :nn",m);
for(i=n-1;i>=0;i--)
{
printf("%d",A[i]);
s=s+A[i];
}
printf("nnThe number of digits is %d.nn",n);
printf("The sum of the digits is %d.",s);
getch();
}
POWER DIGIT SUM
15