Showing posts with label Math. Show all posts
Showing posts with label Math. Show all posts

Friday, March 18, 2016

C program to find Transpose of Matrix.

Write a C program to find Transpose of Matrix 

This C program prints the Transpose of supplied Matrix.

C Program source code

#include<stdio.h>
#include<conio.h>
#define MAX 100
int main()
{
 int i,j,r,c,m[MAX][MAX];
 printf("Enter the order of matrix:\n");
 scanf("%d%d",&c,&r);
 printf("Enter a %d*%d matrix:\n",c,r);
 for(i=0;i<c;i++)
 {
  for(j=0;j<r;j++)
  {
   scanf("%d",&m[i][j]);
  }
 }
 printf("Matrix before transpose:\n");
 for(i=0;i<c;i++)
 {
  for(j=0;j<r;j++)
  {
   printf("%d\t",m[i][j]);
  }
  printf("\n");
 }
 printf("Matrix after transpose:\n");
 for(j=0;j<r;j++)
 {
  for(i=0;i<c;i++)
  {
   printf("%d\t",m[i][j]);
  }
  printf("\n");
 }
 getch();
 return(0);
}
 

You can Browse related article below for more information and program code related to different math operation.   Does above is helpful , Post you views in comment    

DO NOT MISS OTHER C PROGRAMMING TUTORIAL

* indicates required



C program to find Transpose of matrix



C program to check if the supplied year is leap year or not.

Write a C program to check if the supplied year is leap year or not. 

This C program check if the supplied year is leap year or not.

C Program source code

#include<stdio.h>
#include<conio.h>
int main()
{
 int y;
 printf("Enter a year:\n");
 scanf("%d",&y);
 if(y%400==0)
 {
  printf("Its a leap year.");
 }
 else if(y%100==0)
 {
  printf("Its not a leap year,");
 }
 else if(y%4==0)
 {
  printf("Its a leap year,");
 }
 else
 {
  printf("Its not a leap year,");
 }
 getch();
 return(0);
}
You can Browse related article below for more information and program code related to different math operation.  Does above is helpful , Post you views in comment

DO NOT MISS OTHER C PROGRAMMING TUTORIAL

* indicates required



C program to check if the supplied year is leap year or not.

C program to print even numbers between given two numbers.

Write a C program print even numbers between given two numbers.

This C program prints the even number between the two number supplied by user

C Program source code

#include<stdio.h>
#include<conio.h>
int main()
{
 int i,n1,n2;
 printf("Enter any two numbers:\n");
 scanf("%d%d",&n1,&n2);
 for(i=n1;i<=n2;i++)
 {
  if(i%2==0)
  {
   printf("%d\t",i);
  }
 }
 printf("\nThese are the even numbers between those two numbers.");
 getch();
 return(0);
}

You can Browse related article below for more information and program code related to different math operation.  Does above is helpful , Post you views in comment

DO NOT MISS OTHER C PROGRAMMING TUTORIAL

* indicates required



C program to print even numbers between given two numbers.

Tuesday, February 16, 2016

Cube sum program of individual digit of number in c with description

What is cube sum program written in c ?

In cube sum program , we  find cube of individual digit of a number and find their sum .for example: 123 =  1^3 + 2 ^3 + 3^3.
Cube of individual digit have to be found for that we have to extract each digit .As we know last digit of number can be extract using modulus division (i.e 123%10 = 3 ) , And if we do integer division of given number by 10 , we can get other digit excluding last digit .


Code of  cube sum program:

// Cube sum program  of individual digit of number in c start
#include <stdio.h> 
#include <conio.h>
int main()
{

   int number;


   printf("enter a number to find cube sum");

 
   scanf("%d", &number); 


   int n2,cube,cubesu=0;

   while(number!=0)
     {

        n2 = number%10;

        cube = n2*n2*n2;

        cubesu = cubesu + cube;

        number = number/10; 

      }

    printf("cube sum is %d\t", cubesu);
    getch();
    return 0 ;

// Cube sum program  of individual digit of number in c start
}

How cube sum program works?

To learn this cube sum program we need to know how to explode a given number(i.e 345 = 3 , 4 ,5 ), Here we need modulus division which provide reminder (i.e last digit ) e.g
23%10 = 3 ,so by using modulus division we can extract end digit until one digit remind using loop.If we want to extract first digit we can do integer division e.g
23/10 = 2.By using integer division we can also extract fist digit without last digit e.g 234/10 = 23.

Here for above program:we extract end digit and find cube of end digit  and store in a variable(i.e cubsum) after that we extract first numbers beside last digit ,
loop continue until number is equal to one.

At last we print the cube sum.

Output of  cube sum program in c?

Output of cubesum program c
On screen output of cube sum program

 Download cube sum program of individual digit free



If you have any problem in understanding this cube sum program written in c , please feel free to post in comment about cube sum program .And if you have any other technique to have Cube sum program  of individual digit of number

Cube sum program using function in c

#include <stdio.h>
#include <conio.h>
int main( )
{
    int number;
    printf("enter a number to find cube sum");
    scanf("%d", &number);
    cubesum(number);
}
cubesum(number)
{
    int n2,cube,cubesum1=0;
    while(number!=0)
    {
        n2 = number%10;
        cube = n2*n2*n2;
        cubesum1 = cubesum1 + cube;
        number = number/10;
   
       
       
    }

    printf("cube sum is %d\t", cubesum1);

    getch();
    return 0 ;
}


If you have any problem in understanding this cube sum program written in c using function , please feel free to post in comment about cube sum program .And if you have any other technique to have Cube sum program  of individual digit of number using function in c