April 19, 2024

Blogs Tab

Read Latest News here at Blogs Tab

Learn about Control Statements and Constants in C Programming

3 min read
C programming

Last Updated on March 4, 2022 by Jonathan Lopez

C is a procedural computer programming language developed by Dennis Ritchie between 1972 and 1973. C can be used to develop software such as databases, operating systems, compilers, and many more. C language can also be an excellent programming language for beginners.

 

C programming language is a must-know for students and working professionals who want to become better Software Engineers, especially if they work in the Software Development field. C was the first used for system development, namely for the programmes that make up an operating system. C was chosen as a system development language because it generates code that executes nearly as quickly as assembly language code.

Applications of C Programming

  • Operating Systems
  • Language Compilers
  • Assemblers
  • Text Editors
  • Language interpreters

Benefits of C Programming Language

Here are a few reasons why programmers choose the C language for running a program:

  • Structured language.
  • It is very easy to understand and learn.
  • It also generates very efficient programs.
  • It helps you handle various low-level activities.
  • The compilation of C programs can occur on various computer programs.

 

Facts About the C Programming Language

  • The C language came into existence for writing an OS known as the UNIX operating system.
  • This language is the successor of the B language, which came into existence in the early 1970s.
  • The ANSI (American National Standard Institute) formalized this language in 1988.
  • The creators of this language have totally written the UNIX OS in C.
  • As of today, the C language is the most popular and widely used programming language.
  • Programmers have implemented a majority of the futuristic, avant-garde tools and software using the C language.

Control Statements in C Programming

Control statements used in the C language facilitate a user to specify a program control’s flow. A control statement in C also helps to determine whether other statements will be executed. It also allows users to specify the order of execution of the instructions present in a program.

 

The advantages of statements are mainly:

  • It makes it possible for the user to program certain decisions
  • Perform various tasks repeatedly
  • Jump from any one section of the code to a different section

 

Types of Statements

  • If statement
  • Switch Statement
  • Conditional Operator Statement
  • Goto Statement
  • Loop Statements

Constants in C Programming

A constant in C programming is a value or variable that can’t be changed in a programme. It is very similar to variables in the C programming language, but during execution of a programme it can hold only a single variable. It means that once the value is assigned to the constant, it can’t be changed throughout the execution of the programme.

 

There are many types of constants in C programming. The two major categories are:

  • Primary Constants
  • Secondary Constants

Types of Constants in C

Type of Constants Data type Example of Data type
Integer constants int 23, 738, -1278, etc.
unsigned int 2000u, 5000U, etc.
long int, long long int 325,647 1,245,473,940
Floating-point or Real constants doule 500.987654321
float 20.987654
Octal constant int Example: 013 /*starts with 0 */
Hexadecimal constant int Example: 0x90 /*starts with 0x*/
character constants char Example: ‘X’, ‘Y’, ‘Z’
string constants char Example: “PQRS”, “ABCD”

About Author