.

C Programming Elements Assignment Help

Elements of C

Every language has basic elements and syntax for programming. The basic elements in C are

  • Character set
  • Variables
  • Data types
  • Constant
  • Keywords
  • Variables
  • Declaration
  • Expression
  • Statements etc.

C Programming Elements Assignment Help By Online Tutoring and Guided Sessions from assignmenthippo.com


All these are combined to construct an efficient program.

Character set

The basic character set are:

Alphabets

Upper case: A, B, C………Z

Lower Case:a, b, c……….z

Digits

0,1,2……….9

Escape sequences

Escape sequences are used to perform specific task like editing or printing character on the screen from keyboard through the combination of blackslah(\) and some characters.

Escape Sequence

Meaning

\a

Alarm or Beep

\b

Backspace

\f

Form Feed

\n

New Line

\r

Carriage Return

\t

Tab (Horizontal)

\v

Vertical Tab

\\

Backslash

\'

Single Quote

\"

Double Quote

\?

Question Mark

\nnn

octal number

\xhh

hexadecimal number

\0

Null

Some coding examples of escape sequences

Example 1.

#include <stdio.h>

int main(void)

printf("Welcome to\a C");

return (0);

Output:

Welcome to C

Explanation

The output generates beep sound after printing welcome to and before the word C.

Example 2.

#include<stdio.h>

int main()

printf("Interesting\n\*c\* language\n\"Do you already know C programming\"");

return 0; 

Output

Interesting

*c* language

"Do you know C language"

Explanation:

\n-Moves the cursor to the beginning of the next line. \*-presents the character with \.

Reserved words/Keywords

There are 32 keywords available in C. These keywords are having predefined meaning in C. They are written in lowercase. The keywords are given below-

auto

double

int

struct

break

else

long

switch

case

enum

register

typedef

char

extern

return

union

continue

for

signed

void

do

if

static

while

default

goto

sizeof

volatile

const

float

short

unsigned

Identifiers

C program can be constructed either by using keywords or identifiers. Keywords are fixed by C environment. These are not changed by users. Identifier are user defined words are used to identify entities like variables, arrays, structures, unions, pointers etc.

Rules for naming identifiers

  • Identifier cannot be a keyword. Keywords are reserved.
  • Identifier should consist only of letters (lower or upper case), numbers, and the underscore character. That means the name cannot contain symbols (except the underscore) nor whitespace (spaces or tabs).
  • First character must begin with a letter (lower or upper case) or an underscore. It cannot begin with a number.
  • C is case sensitive. In C environment upper case letters and lower case are considered different. For example, identifiers pi ,PI,Pi,pI are different.

Some examples of valid identifier names are:

Radius, net_pay, area

.