How To: Programming in C:Getting Started[Part 1]

Programming in C:Getting Started[Part 1]

What is Programming? Why need to learn? How to get started? Which language to choose?

While surfing web, you must be encountering various softwares, games, etc. and might be thinking to make one, but don't know where to start. Here, I am starting series in Programming.

So, without wasting time, let's start.

Programming is an art. With knowledge of programming, you can create amazing things. It teaches how to think and develops your logical problem solving skills.

Then question arises, why need to learn programming when we already have wide variety of softwares, we have programmers, we have buddies (yeah, we have friends who know programming and show attitude)? But don't you think, it would be great if you make your own softwares and kick ass those who show attitude.

Hey, admin there are many programming languages, which language should I choose? You might be thinking this question. Your colleague, friend might have suggested different programming languages. It's about comfort, They feel comfortable in their languages and may be specialized. But I strongly suggested that you should learn C first. Then you may proceed to other languages and choose one to specialize on it.

What is C?

C is a general purpose, high level programming language. It was initially designed at AT & T's Bell Labs. It was written by Dennis Ritchie in 1972. It wasn't made the official Bell Labs Programming language. The language replaced the most familiar languages of that time like PL/I, ALGOL, FORTAN, APL etc. C was preferred due to its simple, easy to use structure. Today many software as well as operating system is written in C as it can interact with hardware more efficiently than any other programming language.

Starting C..............

To learn how to write programs in C, we must first know what alphabets, numbers and special symbols are used in the language. Then we will learn how constants, variables and keywords are constructed and how these are lined-up to form a program.

  • The C Character Set:-Character set is a group of characters that a language can recognize. A character is defined as any alphabet, digit or special symbol used to represent information. Below are the character set supported by C language.

(a) Alphabets: A,B……….Y,Z and a,b,……….y,z
(b) Digits: 0,1,2,3,4,5,6,7,8,9
(c) Special Symbols: ~,`,!,@,#,%,^,&,(,),-,+,=,|,\,{,},,,:,;,",',<,>,,.,?,/,$,

  • Constants:-A constant is a entity in a program whose value in a program does not change.

Types of C Constants:
(a) Primary Constants: Integer Constant, Real Constant, Character Constant.
(b) Secondary Constants: Array, Pointer, Structure, Union, Enum, etc..

For now, we will go through Primary Constants only and will learn Secondary Constants in subsequent chapters.

How to construct Integer Constants:
(i) It must have at least one digit.
(ii) It must not have a decimal point.
(iii) It can be either positive or negative.
(iv) No special characters are allowed within the constant.
(v) Range depends upon the compiler.
Eg: 800, -200, +32, 45, etc……

How to construct Real Constants:
(i) It must have at least one digit.
(ii) It must have a decimal point.
(iii) It can be either positive or negative.
(iv) No special characters are allowed within the constant.
Note: If Real Constant is too small or too large, you should express the constant in exponential form.
Eg: 999.9, -444.987, +7.8e-9, -8.9e+2, etc………

How to construct Character Constants:
(i) It is a type of constant representing a single alphabet, a single digit, a single special symbol, etc….
(ii) Maximum length of the constant can be 1 character.

  • Variable:- Variable is a entity in a program whose value may change during run time. Basically, memory locations contain constants whose names are given upon variables. The same type of variable can hold the same type of constant.

How to construct variables:
(a) A variable name can be any combination of alphabets, digits, and underscore.
(b) A variable name cannot start with a digit. However, it can start with underscore.
(c) No special character other than underscore is allowed.
Eg: int a = 10;
char c = 'A';
float b = 78.9;

  • Keywords:- Keywords also known as Reserved Words are the words whose meaning is already present in the compiler. They cannot be used as the variable names. There are 32 keywords available in C language:

auto, double, int, struct
break, else, long, switch
case, enum, register, typedef
char, extern, return, union
const, float, short, unsigned
continue, for, signed, void
default, goto, sizeof, volatile
do, if, static, while

First C Program:

We now are loaded with the knowledge of variables, constants, keywords, character set. We will now move further and create out first C program.

Program-1:HelloWorld.c

#include <stdio.h>

int main()
{
printf("Hello World, this is my first C program.");
return 0;
}

Do not worry by seeing this program.
I will explain each and every part of the program in detail in Part 2.

Just updated your iPhone? You'll find new emoji, enhanced security, podcast transcripts, Apple Cash virtual numbers, and other useful features. There are even new additions hidden within Safari. Find out what's new and changed on your iPhone with the iOS 17.4 update.

Be the First to Comment

Share Your Thoughts