Try complex problems of C at home
Q. Find the sum of the following series Sn=1/1!+1/2!+1/3!+......... This is a bit more complex problem of C[c] #include
#include
long int fact(int);
void main()
{
int i;
int term=0;
float sum=0;
int num;
clrscr();
printf(“\nHow many terms do you want=”);
scanf(“%d”,&num);
for(i=1;i<=num;i++) { sum=sum+((float) 1/fact(i)); } printf("\nThe sum is %.2f",sum); getch(); } long int fact(int j) { int k; long int fa=1; for(k=1;k<=j;k++) { fa=fa*k; } return fa; } [/c]
Q. Write a program that adds the individual rows of a two dimensional matrix of m by n and stores a sums of rows in a single dimensional array using function by using a function[c] #include
#include
#define R 10
#define C 10
void add_mat(int A[R][C],int B[R],int p,int q);
void main()
{
int a[R][C],b[R];
int i,j;
int m,n;
clrscr();
printf(“\nEnter the rows and column of a matrix”);
scanf(“%d%d”,&m,&n);
for(i=0;i
Q. Write a program in C to print the Armstrong number that lies in between 100 to 1000 by using any kind of function.This is little complex problem of C.This is a tricky problem of C[c] #include
#include
#include
void prime_series();
void main()
{
clrscr();
prime_series();
getch();
}
void prime_series()
{
int r,sum;
int n,temp;
int i;
for(i=100;i<=1000;i++)
{
n=i;
temp=i;
sum=0;
while(n>0)
{
r=n%10;
sum=sum+pow(r,3);
n=n/10;
}
if(temp==sum)
{
printf(“\n%d is a armstrong number\n”,sum);
}
}
getch();
}
These are little Complex Problems of C for the beginners.I recommend you to have a look on the code and try by yourself in the IDE.This will improve your coding skills.If you have any questions or queries, then send me the mail.I am happy to respond you via mail.