- Jun 26, 2008 In this tutorial I show you an example of a simple function. The basics of BASIC, the programming language of the 1980s. Dev C First Program in Urdu 1st Program Start Coding.
- For example, 10 can be expressed as the sum of two prime numbers 7 + 3, 5 + 5. Write a C program that accept an integer (n) from the user and outputs the number of combinations that express n as a sum of two prime numbers. Go to the editor Note: n should be greater than or equal to 4 and less than or equal to 50,000.
C++ Basic Syntax
Example explained. Line 1: #include is a header file library that lets us work with input and output objects, such as cout (used in line 5). Header files add functionality to C programs.
- C Programming Tutorial
- C Programming useful Resources
- Selected Reading
C programming is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system. C is the most widely used computer language. It keeps fluctuating at number one scale of popularity along with Java programming language, which is also equally popular and most widely used among modern software programmers.
C programming language is a MUST for students and working professionals to become a great Software Engineer specially when they are working in Software Development Domain. I will list down some of the key advantages of learning C Programming:
- Easy to learn
- Structured language
- It produces efficient programs Traktor 2 pro installer.
- It can handle low-level activities
- It can be compiled on a variety of computer platforms
- C was invented to write an operating system called UNIX.
- C is a successor of B language which was introduced around the early 1970s.
- The language was formalized in 1988 by the American National Standard Institute (ANSI).
- The UNIX OS was totally written in C.
- Today C is the most widely used and popular System Programming Language. C program using dev c++.
- Most of the state-of-the-art software have been implemented using C.
- Today's most popular Linux OS and RDBMS MySQL have been written in C.
Just to give you a little excitement about C programming, I'm going to give you a small conventional C Programming Hello World program, You can try it using Demo link.
Syntax Of C++ Program
C was initially used for system development work, particularly the programs that make-up the operating system. C was adopted as a system development language because it produces code that runs nearly as fast as the code written in assembly language. Some examples of the use of C are -
- Operating Systems
- Language Compilers
- Assemblers
- Text Editors
- Print Spoolers
- Network Drivers
- Modern Programs
- Databases
- Language Interpreters
- Utilities
This tutorial is designed for software programmers with a need to understand the C programming language starting from scratch. This C tutorial will give you enough understanding on C programming language from where you can take yourself to higher level of expertise.
Before proceeding with this tutorial, you should have a basic understanding of Computer Programming terminologies. A basic understanding of any of the programming languages will help you in understanding the C programming concepts and move fast on the learning track.
- C Programming Tutorial
- C Programming useful Resources
- Selected Reading
You have seen the basic structure of a C program, so it will be easy to understand other basic building blocks of the C programming language.
Tokens in C
A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. For example, the following C statement consists of five tokens −
The individual tokens are −
Semicolons
In a C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.
Given below are two different statements −
Comments
Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminate with the characters */ as shown below −
You cannot have comments within comments and they do not occur within a string or character literals.
![Syntax Syntax](/uploads/1/2/6/2/126251478/250148343.png)
Identifiers
A C identifier is a name used to identify a variable, function, or any other user-defined item. An identifier starts with a letter A to Z, a to z, or an underscore '_' followed by zero or more letters, underscores, and digits (0 to 9).
C does not allow punctuation characters such as @, $, and % within identifiers. C is a case-sensitive programming language. Thus, Manpower and manpower are two different identifiers in C. Here are some examples of acceptable identifiers −
Keywords
![C++ basic syntax C++ basic syntax](/uploads/1/2/6/2/126251478/609172023.jpg)
The following list shows the reserved words in C. These reserved words may not be used as constants or variables or any other identifier names.
auto | else | long | switch |
break | enum | register | typedef |
case | extern | return | union |
char | float | short | unsigned |
const | for | signed | void |
continue | goto | sizeof | volatile |
default | if | static | while |
do | int | struct | _Packed |
double |
Whitespace in C
A line containing only whitespace, possibly with a comment, is known as a blank line, and a C compiler totally ignores it.
Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins. Therefore, in the following statement −
there must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them. On the other hand, in the following statement −
no whitespace characters are necessary between fruit and =, or between = and apples, although you are free to include some if you wish to increase readability.