What is a C programme

                                                What is a Programme  

A programme is a collect ion of some or huge instructions, those instructions are giving by the programmer with the help of keyword, header file, token, function ( library function, user define function), macro, conditional statement like if, else , switch statement, loop statement like for loop, while loop, Do while  loop etc.

# include: is a directives often called include, add a file with the programme  to use the file in our programme.

<stdio.h> : is a header file which contain library function and some other feature.
Main () : main is a function which is a primary function of  C programme because the execution of every C programme is start from main function.
Write a programme to show a string:

# include <stdio.h>
void main ()
{
                Printf(“ computer is an electronic calculating device”);
}

OUTPUT:

Computer is a electronic calculating device

DISCUSSION:

If the programme name is “pro1.c “ that means pro1.c is a C file where we include “stdio.h” file which is a header file and the definition of the library function like printf, scanf etc are present in the header file, if couldn’t include the header file in our programme then we are not able to use the library functions which are present in the header file. Here we use printf(“computer is an electronic calculation device” );  printf() is a library function used to show something in the computer screen.

Programming and complexity

A ‘C’ programme is a process to solve a problem of a proper way, when we get a problem at first we have to analysis the problem that what is the problem and what is the requirement of the programme, we can solve a problem at many way of different techniques and different styles but we have to choose the most proper way and the simplest way that we can solve the problem easily. The aim of every programmer should minimize the complexity, complexity means the processing time and effort to run the programme are required for the programme, if we consider two program which one is lower space required and run time is also low that will be a better quality programme than others.

Describe the complexity with sweet able example:

PROGRAMMING NO 1:

#include<stdio.h>
#include<conio.h>
int main()
{
      int a[20],n,temp,i,j,comp=0,inter=0;
      printf("How many number do you want to Enter? \n");
      scanf("%d",&n);
      printf("\n Enter Values \n");
      for(i=0;i<n;i++)
          {
              scanf("%d",&a[i]);
          }
     for(j=0;j<n-1;j++)
          for(i=0;i<n-1-j;i++)
             {
                  comp=comp+1;
                  if(a[i]>a[i+1])
                     {
                            temp=a[i];
                            a[i]=a[i+1];
                            a[i+1]=temp;
                            inter=inter+1;
                     }
            }

 printf("\n The Sorted list Is \n");
  for(i=0;i<n;i++)
       printf("%d ",a[i]);

 printf("\n The Number Of Comparision Is %d ",comp);
 printf("\n The Number Of Interchange is %d ",inter);

}

OUTPUT:
worst case complexity:  When the data which will be short are




best case :




















PROGRAMMING NO 2:

#include<stdio.h>
#include<conio.h>
int main()
{
      int a[20],n,temp,i,j,comp=0,inter=0;
      printf("How many number do you want to Enter? \n");
      scanf("%d",&n);
      printf("\n Enter Values \n");
      for(i=0;i<n;i++)
          {
              scanf("%d",&a[i]);
          }
     for(j=0;j<n-1;j++)
          for(i=0;i<n-1-j;i++)
             {
                  comp=comp+1;
                  if(a[i]>a[i+1])
                     {
                            temp=a[i];
                            a[i]=a[i+1];
                            a[i+1]=temp;
                            inter=inter+1;
                     }
            }

 printf("\n The Sorted list Is \n");
  for(i=0;i<n;i++)
       printf("%d ",a[i]);

 printf("\n The Number Of Comparision Is %d ",comp);
 printf("\n The Number Of Interchange is %d ",inter);

}


OUTPUT:
worst case complexity:







Best case complexity:









































Translate