Wanna Know what is c?

                    ☆INTRODUCTION 


•WHAT IS C ?

C is general-purpose, high level language  that was initially developed by Dennis Ritchie between 1969 and 1973  at BELL LABS . He was greatest computer scientist . It was created from “ALGOL”, “BCL”  and “B” programming languages.  'C' is a powerful programming language which is strongly associated with the UNIX operating system.
   Even most of the UNIX operating system is coded in 'C'. Initially 'C' programming was limited to the UNIX operating system, but as it started spreading around the world, it became commercial, and many compilers were released for cross-platform systems.

           Today 'C' runs under a variety of operating systems and hardware platforms. As it started evolving many different versions of the language were released. At times it became difficult for the developers to keep up with the latest version as the systems were running under the older versions.    

                 To assure that 'C' language will remain standard, American National Standards Institute (ANSI) defined a commercial standard for 'C' language in 1989. Later, it was approved by the International Standards Organization (ISO) in 1990. 'C' programming language is also called as 'ANSI C'.

           Languages such as C++/Java are developed from 'C'. These languages are widely used in various technologies. Thus, 'C' forms a base for many other languages that are currently in use
• WHY TO LEARN C?

1. 'C' is a base language for many programming languages. So, learning 'C' as the main language will play an important role while studying other programming languages.
2. It shares the same concepts such as data types, operators, control statements and many more.
3. It is a simple language and provides faster execution
4. It is structured language.
5. It can be complied on a variety of computer platform.
6. It can handle low level activities.

• USES OF C .

1. It is widely used in IOT applications.
2. It is used in developing an operating system.Operating systems such as Apple's OS X, Microsoft's Windows, and Symbian are developed using 'C' language.
3. 'C' language is widely used in embedded systems.
4. It is used for developing system applications.
5. It is widely used for developing desktop applications.
6. Most of the applications by Adobe are developed using 'C' programming language.
7. It is used for developing browsers and their extensions. Google's Chromium is built using 'C' programming language.
8. It is used to develop databases. MySQL is the most popular database software which is built using 'C'.
9. It is used for compiler production.


Why Should You Learn C?

There are an awful lot of programming languages available right now -- everything from the extremely high level (such as Visual Basic) to the low level power of assembly, and a good variety of specialized options in between (PerlRuby, and Python are good choices for many tasks). Java has also become quite the hot programming language for some tasks, in part because of its large API and in part because the virtual machine provides some elements of security. (Garbage collection is another nice feature and can make programmers much more efficient.)

Advantages And Disadvantages of C language: 

First of all, let us discuss what makes C language the mother of all languages. There are various benefits of C programming that depends on these positive points which can surely define the functionality of C in a better manner.

1. Advantages of C Programming Language

1.1. Building block for many other programming languages

C is considered to be the most fundamental language that needs to be studied if you are beginning with any programming language. Many programming languages such as Python, C++, Java, etc are built with the base of the C language.

1.2. Powerful and efficient language

C is a robust language as it contains many data types and operators to give you a vast platform to perform all kinds of operations.

 

1.3. Portable language

C is very flexible, or we can say machine independent that helps you to run your code on any machine without making any change or just a few changes in the code.

 

1.4. Built-in functions

There are only 32 keywords in ANSI C, having many built-in functions. These functions are helpful when building a program in C.

 

1.5. Quality to extend itself

Another crucial ability of C is to extend itself. We have already studied that the C language has its own set of functions in the C library. So, it becomes easy to use these functions. We can add our own functions to the C Standard Library and make code simpler.

1.6. Structured programming language

C is structure-based. It means that the issues or complex problems are divided into smaller blocks or functions. This modular structure helps in easier and simpler testing and maintenance.

 

1.7. Middle-level language

C is a middle-level programming language that means it supports high-level programming as well as low-level programming. It supports the use of kernels and drivers in low-level programming and also supports system software applications in the high-level programming language.

1.8. Implementation of algorithms and data structures

The use of algorithms and data structures in C has made program computations very fast and smooth. Thus, the C language can be used in complex calculations and operations such as MATLAB.

1.9. Procedural programming language

C follows a proper procedure for its functions and subroutines. As it uses procedural programming, it becomes easier for C to identify code structure and to solve any problem in a specific series of code. In procedural programming C variables and functions are declared before use.

1.10. Dynamic memory allocation

C provides dynamic memory allocation that means you are free to allocate memory at run time. For example, if you don’t know how much memory is required by objects in your program, you can still run a program in C and assign the memory at the same time.

 

1.11. System-programming

C follows a system based programming system. It means the programming is done for the hardware devices.

So, with this, we are aware of why C considered a very powerful language and why is it important to know the advantages of C?

When we study anything new, it becomes important to know the benefits that we gain from that technology. This allows us to grow our interest and implement our knowledge in a practical scenario. Now, let us move on to the “Advantages and Disadvantages of the C Programming Language”.

2. Disadvantages of C Programming language

We have already discussed the advantages of C.

You might be thinking about why we are not approaching the language practically and studying the theoretical part in every tutorial. It is because if you will understand the basic functionalities of the language and the methods or operation of the programming language, it becomes easy for you to know whether this language is suitable for your career or not.

Also, with the basic knowledge of the C language, you can understand the flow of any program.

So, now let us see what the limitations of C programming language are-

1. Concept of OOPs

C is a very vast language, but it does not support the concept of OOPs (Inheritance, Polymorphism, Encapsulation, Abstraction, Data Hiding). C simply follows the procedural programming approach.

2. Run-time checking

In the C programming language, the errors or the bugs aren’t detected after each line of code. Instead, the compiler shows all the errors after writing the program. It makes the checking of code very complex in large programs.

3. Concept of namespace

C does not implement the concept of namespaces. A namespace is structured as a chain of commands to allow the reuse of names in different contexts. Without namespaces, we cannot declare two variables of the same name.

But, C programming lacks in this feature, and hence you cannot define a variable with the same name in C.

4. Lack of Exception Handling

Exception Handling is one of the most important features of programming languages. While compiling the code, various anomalies and bugs can occur. Exception Handling allows you to catch the error and take appropriate responses. However, C does not exhibit this important feature.

5. Constructor or destructor

C does not have any constructor or destructor.

Constructors & Destructors support basic functionality of Object Oriented Programming. Both are member functions that are created as soon as an object of the class is created. You will be studying constructor and destructor in detail later on.

6. Low level of abstraction

C is a small and core machine language that has minimum data hiding and exclusive visibility that affects the security of this language.


Some basic programmes in c:

 1.ADDITION OF TWO NUMBERS:


include<stdio.h>
 
int main()

 
{

 
 int a,b,c;

 
 printf("Enter first number\n");

 
 scanf("%d",&a);

 
 printf("Enter second number\n");

 
 scanf("%d",&b);

 
 c=a-b;

 
 printf("Sub=%d",c);

 
 

}
OUTPUT: 
 Enter first number
 20 
 Enter second number
 50 
 Add=70 


2.SUBTRACTION OF TWO NUMBERS :




#include<stdio.h>
 
int main()

 
{

 
 int a,b,c;

 
 printf("Enter first number\n");

 
 scanf("%d",&a);

 
 printf("Enter second number\n");

 
 scanf("%d",&b);

 
 c=a-b;

 
 printf("Sub=%d",c);

 
 

 }

OUTPUT: 
 first number
 200
 Enter second number
 50
 Sub=150

    3.MULTIPLICATION OF TWO NUMBERS

#include<stdio.h>

int main()

{

 int a,b,c;

 printf("Enter first number\n");

 scanf("%d",&a);

 printf("Enter second number\n");

 scanf("%d",&b);

 c=a*b;

 printf("Multiply=%d",c);

 

}

OUTPUT:
 Enter first number
 20
 Enter second number
 50 
 Multiply =1000
 
  4.DIVISION OF TWO NUMBERS:
#include<stdio.h>

int main()

{

 int area,h,w;

 printf("Enter height of rectangle\n");

 scanf("%d",&h);

 printf("Enter width of rectangle\n");

 scanf("%d",&w);

 area=h*w;

 printf("Area of rectangle=%d",area);

}

 
OUTPUT: 
 Enter first number 
 200
 Enter second number 
 50 
 Div=4 

 5.AREA OF RECTANGLE :
#include<stdio.h>

int main()

{

 int area,h,w;

 printf("Enter height of rectangle\n");

 scanf("%d",&h);

 printf("Enter width of rectangle\n");

 scanf("%d",&w);

 area=h*w;

 printf("Area of rectangle=%d",area);

}

 

OUTPUT: 
 Enter first number
 4 
 Enter second number 
 6 
 Area of Rectangle=24 6.
    
6AREA OF SQUARE:
#include<stdio.h>

int main()

{

 int area,side;

 printf("Enter side of square\n");

 scanf("%d",&h);

 area=side*side;

 printf("Area of square=%d",area);

}        


OUTPUT: 
 Enter Side of Square 
 4 
 Area of square =16 7.

   7. Area of Circle:
#include<stdio.h>

int main()

{

float area,r;

printf("Enter radius of circle\n");

scanf("%f",&r);

area=3.14*r*r;

printf("Area of Circle=%f",area);

}

OUTPUT: 
 Enter radius of circle
 2 
 Area of Circle =12.56

 8.Area of triangle:
#include<stdio.h>

int main()

{

float area,base,height;

printf("Enter base \n");

scanf("%f",&base);

printf("Enter height \n");

scanf("%f",&height);

area=0.5*base*height;

printf("Area of triangle=%f",area);

}

OUTPUT: 
 Enter base 
 5
 Enter height
 4
 Area of triangle =10.00

 9.Input marks of five subject(Math,Physics,Chemistry,Hindi and English) and Find average:

#include<stdio.h>

int main()

{

float p,c,m,h,e,avg;

printf("Enter marks in physics \n");

scanf("%f",&p);

printf("Enter marks in chemistry \n");

scanf("%f",&c);

printf("Enter marks in math \n");

scanf("%f",&m);

printf("Enter marks in hindi \n");

scanf("%f",&h);

printf("Enter marks in english \n");

scanf("%f",&e);

avg=(p+c+m+h+e)/5;

printf("Average of result=%f",avg);

}

OUTPUT:
Enter marks in physics
 45 
 Enter marks in chemistry
 65
 Enter marks in math
 87
 Enter marks in hindi
 75 
 Enter marks in english
 94
 Average of result=73.19

 10.Simple interest programme

#include<stdio.h>

int main()

{

float p,r,t,si;

printf("Enter principle\n");

scanf("%f",&p);

printf("Enter rate of interest \n");

scanf("%f",&r);

printf("Enter time \n");

scanf("%f",&t);

si=(p*r*t)/100;

printf("Simple Interest=%f",si);

}

 

OUTPUT :
 Enter principle
 5000 
 Enter rate of interest
 5
 Enter time 10 Simple interest =2500
  
 11.Swapping of TWO NUMBERS using THITD variable
 METHOD 1.

#include<stdio.h>

int main()

{

int a=10,b=20,c;

printf("Before swapping a=%d and b=%d\n",a,b);

c=a;

a=b;

b=c;

printf("After swapping a=%d and b=%d\n",a,b);

}
METHOD 2:
#include<stdio.h>

int main()

{

int a=10,b=20,c;

printf("Before swapping a=%d and b=%d\n",a,b);

c=a+b;

a=c-a;

b=c-b;

printf("After swapping a=%d and b=%d\n",a,b);

}

 

METHOD 3:

#include<stdio.h>

int main()

{

int a=10,b=20;

printf("Before swapping a=%d and b=%d\n",a,b);

a=a+b;

b=a-b;

a=a-b;

printf("After swapping a=%d and b=%d\n",a,b);

}

 

OUTPUT:
 Before swapping a=10 and b=20 
 After swapping a=20 and b=10

Comments

Popular posts from this blog

Java vs C++

STRUCTURE

SWITCH PROGRAMME