Showing posts with label Sum. Show all posts
Showing posts with label Sum. Show all posts

Write the procedure , which is one of a sum , a product and a geometric average in the panel for the NxM elements are located on opposite diagonal and main diagonal . Remind ! Counting only odd elements !

Write the procedure , which is one of a sum , a product and a geometric average in the panel for the NxM elements are located on opposite diagonal and main diagonal . Remind ! Counting only odd elements !


Schreib die Prozedur, die zählt eine Summe, einen Produkt und einen geometrischen Durchschnitt in der Tafel NxM fur die Elemente befinden sich über gegenläufigen Diagonale und unter hauptsächlichen Diagonale. Erinner! Zähl nur für ungerade Elementen!


Solution For C Program :

//Schreib die Prozedur, die zählt eine Summe, einen Produkt und einen geometrischen Durchschnitt in der Tafel NxM fur die Elemente befinden sich über gegenläufigen Diagonale und unter hauptsächlichen Diagonale. Erinner! Zähl nur für ungerade Elementen!

void prozedur (int tafel[N][M])
{
int i=0,j=0,Summe=0,Produkt=1;
float Durchschnitt;
for(i;i<N;i++)
   for(j;j<M;j++)
      if(i>j && i<(N-1)-j && tafel[i][j]!=0)
         Summe+=tafel[i][j];
         Produkt*=tafel[i][j];
Durchschnitt=Summe/(N*M);
printf("Summe ergibt: %d Produkt ergibt: %d geometrischer Durchschnitt ergibt: %d,Summe,Produkt,Durchschnitt);
}

C Program To Find Sum and Difference Of Two Matrices

How to write a C Program To Find Sum and Difference Of Two Matrices in C Programming Language ?


Solution For C Program :

/*C Program To Find Sum and Difference Of Two Matrices.*/

#include<stdio.h>
#include<conio.h>
void main()
{
int mat1[3][2],mat2[3][2];
int i,j;
clrscr();
printf("enter the Ist matrix\n");
for(i=0;i<3;i++)
    {
    for(j=0;j<2;j++)
        {
        scanf("%d",&mat1[i][j]);
        }
    }
printf("\n\n\nFirst Entered matrix is:\n");
for(i=0;i<3;i++)
    {
    printf("\n");
    for(j=0;j<2;j++)
        {
        printf("%d\t",mat1[i][j]);
        }
    }
printf("\n\nEnter the 2nd matrix\n");
for(i=0;i<3;i++)
    {
    for(j=0;j<2;j++)
        {
        scanf("%d",&mat2[i][j]);
        }
    }
printf("\n\n\nSecond Entered matrix is:\n");
for(i=0;i<3;i++)
    {
    printf("\n");
    for(j=0;j<2;j++)
        {
        printf("%d\t",mat2[i][j]);
        }
    }

printf("\n\n Sum of the two matrix is:\n");
for(i=0;i<3;i++)
    {
    printf("\n");
    for(j=0;j<2;j++)
        {
        printf("%d\t",mat2[i][j]+mat1[i][j]);
        }
    }
printf("\n\n Difference of the two matrix is:\n");
for(i=0;i<3;i++)
    {
    printf("\n");
    for(j=0;j<2;j++)
        {
        printf("%d\t",mat1[i][j]-mat2[i][j]);
        }
    }
getch();
}

You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program To Print Sum Of n Digit Number

How to write a C Program To Print Sum Of n Digit Number in C Programming Language ?


Solution For C Program  :

/*C Program To Print Sum Of n Digit Number.*/

/*Program works good upto 9-digit.*/
#include<stdio.h>
#include<conio.h>
void main()
{
long int n,rem,sum=0;
clrscr();
printf("Enter the number==>");
scanf("%ld",&n);
while(n>0)
{
rem=n%10;
n=n/10;
sum=sum+rem;
}
printf("%ld",sum);
getch();
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable



C Program Finding the sum of Squares using Recursion

How to write a C Program Finding the sum of Squares using Recursion in C Programming Language ?

Solution For C Program :

/*C Program Finding the sum of Squares using Recursion*/

#include<stdio.h>
void main()
{
int square(int);
int n;
printf("\nEnter N'th Value : ");
scanf("%d", &n);
printf("\nThe Result is : %d.", square(n));
}
int square(int x)
{
int a, b;
if(x == 0) return 0;
if(x == 1) return 1;
a = x - 1;
b = x * x + square(a);
return(b);
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

Give me an integer and I will sum it with the previous natural numbers

How to write a C Program Give me an integer and I will sum it with the previous natural numbers in C Programming Language ?

This C Program Change an Integer Number with Addition of Previous Natural Numbers.
 
Solution:

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int geometric_sum (int a);
  4. int main ()
  5. {
  6.     int a = 0, sum = 0;
  7.     printf("Give me an integer and I will sum it with the previous natural numbers : ");
  8.     scanf("%d", &a);
  9.     sum = geometric_sum(a);
  10.     printf("Result: %d", sum);
  11. }
  12.  
  13. int geometric_sum (int a)
  14. {
  15.     if (== 0)
  16.     {
  17.         printf("Base case!\n");
  18.         return a;
  19.     }
  20.  
  21.     else
  22.     {
  23.         printf("1: sum (%d)\n", a);
  24.         return a + geometric_sum(a-1);
  25.     }
  26.  
  27. }

C Program to Sum of The First and Last Digit Of 'n' Digit Number

How to write a C Program to Sum of The First and Last Digit Of  'n' Digit Number  in C Programming Language ?


  1. int main()
  2. {
  3. int num,len,last;
  4. printf("\nEnter n digit number \n");
  5. scanf("%d",&num);
  6. last=num%10;
  7. while(num>0)
  8. {
  9. num=num/10;
  10. len=len+1;
  11. }
  12. num=num/(pow(10,len-1));
  13. num=num%10;
  14. printf("the result is %d",last+num);
  15. getch();
  16. return 0;
  17.  
  18. }