Sunday, February 25, 2018

C Program : Given an NxN matrix. You have to determine whether the matrix is a triangular matrix.

A matrix is upper triangular if every entry below the diagonal is
0. For example,  
1 1 1
0 0 1
0 0 2
is an upper triangular matrix. (The diagonal itself, and the entries
above and below the diagonals can be zeroes or non-zero integers.) 

A matrix is lower triangular if every entry above the diagonal is
0. For example, 
2 0 0
3 1 0
4 2 2
is a lower triangular matrix. 

A matrix is triangular if it is either upper triangular or lower
triangular or both.  

#include<stdio.h>

int main()
{

  int i, a,n,s=0,countl=0, countu=0;
  scanf("%d",&n);
  if(n>1)
{
  for(int r=0;r<n;r++)
  {
     for(int c=0;c<n;c++)
     {
          scanf("%d",&a);
       if((c>r)&& (a==0))
         countl++;
       if((c<r)&& (a==0))
         countu++;
     
     }
  }

  for(int j=1;j<=n;j++)
  { i=n-j;
    s=s+i;
  }
  if( (countl>=s) || (countu>=s))
  {printf("yes\n");
  
  }
  else
  {
   printf("no\n");
  
  }
}
  else
    printf("no\n");
  return 0;
}

Thanks
Happy Computing !

C program ; To check if given numbers are a Pythagorean triple

#include<stdio.h>

int main(){
     int a,b,c;
 
  scanf("%i", &a);
   scanf("%i", &b);
   scanf("%i", &c);
  if((a*a+b*b==c*c)||(a*a+c*c==b*b)||(b*b+a*a==c*c)||(b*b+c*c==a*a)||(c*c+a*a==b*b)||(c*c+b*b==a*a))
   
  {printf("1");}
  else {printf("0");}
  return 0;
}

Thanks
Happy Computing !

C program : To check whether M is an exact multiple of N

#include<stdio.h>

int main()
{
     int M,N,q;
  scanf("%i %i",&M, &N);
  if((M%N)!=0)
  {printf("0");}
  else{
    q=M/N;
    printf("%i",q);
  }
  return 0;
}

Thanks
Happy Computing !

C program to print alternate letters of a word entered from keyboard



#include<stdio.h>

int main()
{
    char str[100];
    char c='a';
    int i=0;
    printf("type a word \n");

    while(c != '\n')
    {
        c = getchar();
        str[i]=c;
        i++;
    }
    for (int j=0;j<=i;j++)
    {
        printf("%c ",str[j]);
        j++;
    }
return 0;
}

Thanks
Happy computing !

Saturday, February 24, 2018

Steps to output the Assembly Language code of any C program

Dear friends ,

Here are the steps to see/print the assembly code of any C program on your Windows
console /terminal/ command prompt :

1. Write a C program in a C code editor like codeblocks and save it with an extention .c
2. Compile and run it.
3. Once run successfully, go to the folder where you have installed your gcc compiler and give the
    following command to get a ' .s ' file of the ' .c' file
   C:\ gcc> gcc -S <complete path of the C file>  <enter>
 An example command ( as in my case)
   C:\gcc> gcc  -S D:\Aa_C_Certified\alternate_letters.c
  // give the -S gcc command line option to get the ' .s ' file
 // C:\gcc> as -v ENTER
// will give the version of your GNU assembler


     This outputs a ' .s' file of the original  ' .c' file
4 . After this , give the following command
   C;\gcc> cpp filename.s <enter>
// cpp is the C Pre-Processor

   Example command ( as in my case)
   C;\gcc> cpp alternate_letters.s  <enter>
This will print/output the entire Assembly language code of your C program.

Following are screen shots of the output of above commands

To see the version of your gcc compiler give following command
C:\ gcc> gcc -v ENTER



 Thanks
Happy Computing !

Machine Learning :: Same as 'Continuous Learning'

Dear friends,

Here is a link which tells us that machine learning is nothing but to learn continuously from new data and take decisions accordingly.
Through machine learning, the computer system can actually refine the model without the help of any human interaction. This means that as more data enters the machine learning system’s reservoir, it will become more intelligent and the data will become more manageable and easier to interpret.

How machine learning can improve supply chain efficiency

Happy computing ! 😊

Wednesday, February 21, 2018

IGNOU : Frequent Links

Link to Distance programme Admission https://ignouadmission.samarth.edu.in/

what is crystal field theory and why do we need it?

  Calculating CFSE