Showing posts with label Concepts. Show all posts
Showing posts with label Concepts. Show all posts

Thursday, April 18, 2019

Type of Error In C Programming Language

There are three types of errors in C programming 
(1)Syntax errors
(2)Logical errors
(3)Run-time errors

(1) Syntax errors- These errors occur because of wrongly typed statement,  which are not according to the syntax or grammatrical rules of the language.
      For example- In C, if you don't place a semi-colon after the statement (as show below),  it       results in a syntax error. 
      printf("Hello word")
      Error in syntax (semicolon missing) 
      printf("Hello word");
      This statement is syntactically correct. 

(2) Logical errors- These errors occur because of logical incorrect instruction in the program. 
       For example - Let us assume that in a 1000 line program, if there should an instruction,  which multiplies two numbers and is wrongly Written to perform addition. This logically incorrect instruction may produce wrong result. Detecting such errors are difficult. 

(3) Run-time errors- These errors occur during the execution of the program though the program is free from syntax and logical errors.  Some of the most common reasons for these errors are-
       A. When you instruct your computer to divide a number by zero. 
       B. When you instruct your computer to find logarithm of a negative number. 
       C. When you instruct your computer to find the square root of a negative integer. 

Monday, April 15, 2019

Advantages and Disadvantages of 'C' language.

Advantages of C language :

(1) Portability - Program written in C language can be transferred from one machine to another machine. 

(2) Efficiency - program written in C language are fast,efficient and flexible. 

(3) C permits nearly every programming technique like-addressing memory location,manipulation bits etc. 

(4) C is a structure programming language- It allow the use of several programming construct such as sequence construct,selection construct etc. 

(5) Modularity - In C, a given program is divided into a number of module, each of which would perform some specific task. 

Disadvantages of C are:

(1) There is no runtine checking.

(2) There is no strict type checking (for ex:we can pass an integer value for the floting data type). 

(3) As the program extent it is very difficult to fix the bugs. 

To sum n different number using array.

#include<stdio.h> #include<conio.h> Void main()      {          int a[20] n,  s=0,i;          printf("Enter the numbe...