C Programming
C Programming
History of C Programing
C Environment Setup
This section describes how to set up your system environment before you start
doing your
programming using C language.
Before you start doing programming using C programming language, you need
the following
two softwares available on your computer, (a) Text Editor and (b) The C
Compiler.
Text Editor
This will be used to type your program. Examples of few editors include
Windows Notepad,
OS Edit command, Brief, Epsilon, EMACS, and vim or vi. Name and version
of text editor can vary on different operating systems. For example, Notepad
will be used on Windows, and vim or vi can be used on windows as well as
Linux or
UNIX.
The files you create with your editor are called source files and contain
program source
2|P ag e
code. The source files for C programs are typically named with the extension
“.c”.
Before starting your programming, make sure you have one text editor in place
and you
have enough experience to write a computer program, save it in a file, compile
it and finally
Execute it.
The C Compiler
The source code written in source file is the human readable source for your
program. It
needs to be "compiled", to turn into machine language so that your CPU can
actually
execute the program as per instructions given.
This C programming language compiler will be used to compile your source
code into final
executable program. I assume you have basic knowledge about a programming
language
compiler.
Most frequently used and free available compiler is GNU C/C++ compiler,
otherwise you can have compilers either from HP or Solaris if you have
respective Operating Systems.
Following section guides you on how to install GNU C/C++ compiler on
various OS. I'm
mentioning C/C++ together because GNU gcc compiler works for both C and
C++
programming languages.
Why to use C?
C was initially used for system development work, in particular 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 code written in
assembly language. Some examples of the use of C might be:
Semicolons ;
3|P ag e
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 or 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:
C Data Types
In the C programming language, data types refer to an extensive system used for
declaring variables or functions of different types. The type of a variable
determines how much space it occupies in storage and how the bit pattern stored
is interpreted.
The types in C can be classified as follows:
Basic Types: They are arithmetic types and consists of the two types: (a) integer
types and (b) floating-point types.
Integer Types
Floating-Point Types:-
float 4 byte 1.2E-38 to 6 decimal
3.4E+38 places
C Variables:-
A variable is nothing but a name given to a storage area that our programs can
manipulate. Each variable in C has a specific type, which determines the size
and layout of the variable's memory; the range of values that can be stored
within that memory; and the set of operations that can be applied to the variable.
The name of a variable can be composed of letters, digits, and the underscore
character. It must begin with either a letter or an underscore. Upper and
lowercase letters are distinct because C is case-sensitive. Based on the basic
types explained in previous chapter, there will be the following basic variable
types:
the machine.
Float A single-precision floating point
value.
Variable Definition in C:
A variable definition means to tell the compiler where and how much to create
the storage for the variable. A variable definition specifies a data type and
contains a list of one or more variables of that type as follows:
int i, j, k;
char c, ch;
float f, salary;
double d;
C Operators:-
6|P ag e
Relational Operators:-
== Checks if the (A == B) is not
values of two true.
operands are
equal or not, if
yes then
condition
7|P ag e
becomes true.
!= Checks if the (A != B) is true.
values of two
operands are
equal or not, if
values are not
equal then
condition
becomes true.
> Checks if the (A > B) is not
value of left true.
operand is
greater than the
value of right
operand, if yes
then condition
becomes true.
< Checks if the (A < B) is true.
value of left
operand is less
than the value of
right operand, if
yes then
condition
becomes true.
>= Checks if the (A >= B) is not
value of left true.
operand is
greater than or
equal to the
value of right
operand, if yes
then condition
becomes true.
<= Checks if the (A <= B) is true.
value of left
operand is less
than or equal to
the value of right
operand, if yes
then condition
becomes true.
8|P ag e
Logical Operators:-
Decision Making in C
Decision making structures require that the programmer specify one or more
conditions to be evaluated or tested by the program, along with a statement or
statements
to be executed if the condition is determined to be true, and optionally, other
statements to
be executed if the condition is determined to be false.
Following is the general form of a typical decision making structure found in
most of the
programming languages:
if statement
An if statement consists of a boolean expression followed by one or more
statements.
Syntax .The syntax of an if statement in C programming language is:
if(boolean_expression)
{
/* statement(s) will execute if the boolean expression is true */
}
If the boolean expression evaluates to true, then the block of code inside the if
statement will be executed. If boolean expression evaluates to false, then the
first set of
code after the end of the if statement (after the closing curly brace) will be
executed.
C programming language assumes any non-zero and non-null values as true
and if it is
either zero or null then it is assumed as false value.
10 | P a g e
switch statement :-
A switch statement allows a variable to be tested for equality against a list of
values. Each
value is called a case, and the variable being switched on is checked for each
switch case.
Syntax
The syntax for a switch statement in C programming language is as follows:
switch(expression){
case constant-expression :
statement(s);
break; /* optional */
case constant-expression :
statement(s);
break; /* optional */
The constant-expression for a case must be the same data type as the variable in
the
switch, and it must be a constant or a literal.
When a break statement is reached, the switch terminates, and the flow of
control jumps
to the next line following the switch statement.
Not every case needs to contain a break. If no break appears, the flow of
control will fall
through to subsequent cases until a break is reached.
A switch statement can have an optional default case, which must appear at the
end of
the switch. The default case can be used for performing a task when none of the
cases
is true. No break is needed in the default case.
12 | P a g e
while loop in C
A while loop statement in C programming language repeatedly executes a
target
statement as long as a given condition is true.
Syntax
The syntax of a while loop in C programming language is:
while(condition)
{
statement(s);
}
Here, statement(s) may be a single statement or a block of statements.
The condition may be any expression, and true is any nonzero value. The loop
iterates
while the condition is true.
When the condition becomes false, program control passes to the line
immediately
following the loop.
Flow Diagram
13 | P a g e
For Loop in C
A for loop is a repetition control structure that allows you to efficiently write a
loop that
needs to execute a specific number of times.
Syntax
The syntax of a for loop in C programming language is:
for ( init; condition; increment )
Here is the flow of control in a for loop:
1.
The init step is executed first, and only once. This step allows you to
declare and
initialize any loop control variables. You are not required to put a statement
here, as long
as a semicolon appears.
2.
Next, the condition is evaluated. If it is true, the body of the loop is
executed. If it is
false, the body of the loop does not execute and flow of control jumps to
the next
statement just after the for loop.
3.
14 | P a g e
After the body of the for loop executes, the flow of control jumps back up
to
the increment statement. This statement allows you to update any loop
control
variables. This statement can be left blank, as long as a semicolon appears
after the
condition.
4.
The condition is now evaluated again. If it is true, the loop executes and
the process
repeats itself (body of loop, then increment step, and then again
condition). After the
condition becomes false, the for loop terminates.
Flow Diagram
do...while loop in C
15 | P a g e
Unlike for and while loops, which test the loop condition at the top of the loop,
the do...while loop in C programming language checks its condition at the
bottom of the
loop.
A do...while loop is similar to a while loop, except that a do...while loop is
guaranteed to
execute at least one time.
Syntax
The syntax of a do...while loop in C programming language is:
do
{
statement(s);
}while( condition );
Notice that the conditional expression appears at the end of the loop, so the
statement(s)
in the loop execute once before the condition is tested.
16 | P a g e
C programming language allows to use one loop inside another loop. Following
section
shows few examples to illustrate the concept.
Syntax
The syntax for a nested for loop statement in C is as follows:
for ( init; condition; increment )
{
for ( init; condition; increment )
{
statement(s);
}
statement(s);
}
The syntax for a nested while loop statement in C programming language is as
follows:
while(condition)
{
while(condition)
{
statement(s);
}
statement(s);
}
The syntax for a nested do...while loop statement in C programming language
is as
follows:
do
{
statement(s);
do
{
statement(s);
}while( condition );
}while( condition );
break statement in C
17 | P a g e
The break statement in C programming language has the following two usages:
1.
When the break statement is encountered inside a loop, the loop is
immediately
terminated and program control resumes at the next statement following
the loop.
2.
It can be used to terminate a case in the switch statement (covered in the next
chapter).
If you are using nested loops (i.e., one loop inside another loop), the
break statement
will stop the execution of the innermost loop and start executing the next line
of code after
the block.
Syntax
The syntax for a break statement in C is as follows:
break;
C Structures
C arrays allow you to define type of variables that can hold several data items
of the same
kind but structure is another user defined data type available in C
programming, which
allows you to combine data items of different kinds.
Structures are used to represent a record, suppose you want to keep track of
your books in
a library. You might want to track the following attributes about each book:
Title
Author
19 | P a g e
Subject
Book ID
Defining a Structure
To define a structure, you must use the struct statement. The struct statement
defines a
new data type, with more than one member for your program. The format of the
struct
statement is this:
struct [structure tag]
{
member definition;
member definition;
...
member definition;
} [one or more structure variables];
The structure tag is optional and each member definition is a normal variable
definition,
such as int i; or float f; or any other valid variable definition. At the end of the
structure's
definition, before the final semicolon, you can specify one or more structure
variables but it
is optional. Here is the way you would declare the Book structure:
struct Books
Accessing Structure Members
To access any member of a structure, we use the member access operator (.).
The member access operator is coded as a period between the structure variable
name and the structure member that we wish to access. You would use struct
keyword to define variables of structure type. Following is the example to
explain usage of structure:
Practical Program
#include<stdio.h>
20 | P a g e
#include<conio.h >
void main()
{
clrscr();
printf("my name is kailash punjabi.\n");
printf("i reside at:\t109 prem bhuvan,");
printf("\n\t\tbazar road,");
printf("\n\t\tbandra(w),");
printf("\n\t\tmumbai 400050");
getch();
}
Explanation :-
#include<stdio.h> This is header file standard input out
#include<conio.h> This is also header file Console Input Out put
Void main() Main program where u have to write code
Printf It will show out put on turbo C
Getch() it will hold the output.
Clrscr(); it will clear the screen
-
Assignment- 2 (Declaring And Intitalizing Variables)
#include <stdio.h>
#include <conio.h>
void main()
{
//Declaring And Intitalizing Variables
char xyz= 'A';
int inum= 21;
float fnum=87.65;
clrscr();
//Displaying the values with Conversion And Escape Characters
printf("\n\n");
printf("Char is \t= %c \n",xyz);
printf("Int is \t= %d \n",inum);
printf("Float is \t= %f \n",fnum);
getch();
21 | P a g e
#include <stdio.h>
#include <conio.h>
#include<string.h>
void main()
{
//Declaring Variables
int rollno;
float height;
char name[20];
//Use of printf() and scanf() function
clrscr();
#include <stdio.h>
#include <conio.h>
void main()
{
//Declaration and Intialization of the variable
int a,b,c,d;
int sum, multi, div,remainder, minus, increase, decrease;
22 | P a g e
c=25;
d=12;
#include <stdio.h>
#include <conio.h>
void main()
{
//Declaring variables
clrscr();
int a;
char b;
float pi;
// Displaying the size occupied by each data type
23 | P a g e
#include<conio.h>
# include <stdio.h>
void main()
{
int a,b,c;
printf("\n enter the first number:");
scanf("%d", &a);
printf("\n enter the second number:");
scanf("%d “,&b);
// Displaying the numbers before interchanging
printf("\n\n printing the numbers before interchanging");
printf("\n the first number is:%d",a);
printf("\n the second number is:%d",b);
//Interchanging the numbers
c=a;
a=b;
b=c;
// Displaying the numbers after interchanging
printf("\n\n printing the numbers after interchanging");
printf("\n the first number now is:%d",a);
printf("\n the second number now is:%d",b);
getch();
}
#include<conio.h>
#include <stdio.h>
void main()
{
24 | P a g e
float basic,da,hra,salary;
char d[15];
clrscr();
printf("\nEnter Your Name : ");
scanf("%s",&d);
printf("\n enter the basic salary :");
scanf("%f",&basic);
// Calculate the da,hra and salary
da=basic*40/100;
hra=basic*25/100;
salary=basic+da+hra;
//Displaying the details
printf("\nyour name is: %c ",d);
printf("\n\n salary details :");
printf("\n Basic salary is: %f",basic);
printf("\n Dearness Allowance is: %f",da);
printf("\n House Rent Allowance is: %f",hra);
printf("\n\n Total salary earned %f\n",salary);
if(salary>=80000)
{
printf("\nYou are ceo ");
}
else if(salary>=50000)
{
printf("\nYou are purchase manager");
}
else if(salary>=25000)
{
printf("\nyou are sales manager");
}
else
{
printf("\nyou are clerk");
}
getch();
}
#include <stdio.h>
25 | P a g e
#include <conio.h>
void main()
{
int num1,num2, sum;
printf("enter two numbers:");
scanf("%d %d", &num1,&num2);
sum= num1+num2;
if(sum>100)
printf("\n the sum of two numbers is greater than 100\n");
else
printf("\n the sum of two numbers is smaller than 100\n");
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
int age;
char name;
clrscr();
printf("\n enter your name:");
scanf("%s", &name);
printf("\n enter your age:");
scanf("%d", &age);
if (age>=19)
{
printf("\n you are eligiable for voting\n");
}
else
{
printf("\n you are not eligible for voting\n");
}
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
int num1,num2, num3;
clrscr();
printf("\n enter 3 numbers:");
scanf("%d %d %d", &num1,&num2,&num3);
if((num1>num2) && (num1>num3))
printf("\n the largest of three numbers is %d \n",num1);
if((num2>num1) && (num2>num3))
printf("\n the largest of three numbers is %d \n",num2);
if((num3>num1) && (num3>num2))
printf("\n the largest of three numbers is %d \n",num3);
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
char in_char;
printf("\nEnter a character in lower case: ");
scanf("%c", &in_char);
if(in_char=='a' || in_char=='A')
printf("\nThe character input is a vowel a\n");
else if (in_char=='e')
printf("\nThe character input is a vowel e\n");
else if (in_char=='i')
printf("\nThe character input is a vowel i\n");
else if (in_char=='o')
printf("\nThe character input is a vowel o\n");
else if (in_char=='u')
printf("\nThe character input is a vowel u\n");
else
printf("\nThe character input is not a vowel\n");
getch();
27 | P a g e
#include<stdio.h>
#include<conio.h>
void main()
{
//Declaration and Intialization of the variable
int a;
printf("\nEnter Number with in one to seven: ");
scanf("%d",&a);
printf ("you have entered number is %d\n",a);
switch(a)
{
case 1 : printf("you have selected monday");
break;
case 2 : printf("you have selected tuesday");
break;
case 3 : printf("you have selected wednesday");
break;
case 4 : printf("you have selected thursday");
break;
case 5 : printf("you have selected friday");
break;
case 6 : printf("you have selected saturday");
break;
case 7 : printf("you have selected sunday");
break;
default : printf("wrong choice");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
28 | P a g e
{
//Declaration and Intialization of the variable
int a,b,choice,add,sub,div,mul;
clrscr();
printf("\nEnter 1 st Number: ");
scanf("%d",&a);
printf("\nEnter 2nd Number");
scanf("%d",&b);
printf("\nPress 1 for addition\nPress 2 for substraction \nPress 3 for
Division \nPress 4 for multiplication");
scanf("%d",&choice);
add=a+b;
sub=a-b;
div=a/b;
mul=a*b;
switch(choice)
{
case 1 : printf("addition of two num is %d",add);
break;
case 2 : printf("substraction of two num is %d",sub);
break;
case 3 : printf("division of two num is %d",div);
break;
case 4 : printf("multiplication of two num is %d",mul);
break;
default : printf("wrong choice");
}
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
int num1=1, num2=5, count=1;
int product;
while (count<=5)
29 | P a g e
{
product = num1*num2;
printf("Product=%d\n", product);
count = count+1;
num1 = num1+1;
}
getch();
}
Assignment- 15 (While Loop with calculation)
#include<conio.h>
#include<stdio.h>
void main()
{
int x=1,n,r;
clrscr();
printf("enter any number ");
scanf("%d",&n);
while(x<=10)
{
r=n*x;
printf("\n%d*",n);
printf("%d=",x);
printf(" %d ",r);
x++;
}
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
int i=1, j;
while(i <=10)
{
j=1;
30 | P a g e
while (j <= i)
{
printf("*");
j++;
}
printf("\n");
i++;
}
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
int number;
int sum=0;
printf("\nEnter the number:");
scanf("%d", &number);
if (number>0)
{
while(number>0)
{
sum = sum+number;
number = number-1;
printf(“\nnumber value is: %d”,number);
printf(“\nsum is : %d”,sum);
}
printf("\nThe sum %d\n", sum);
}
else
printf("\n%d is not valid.", number);
getch();
}
#include <stdio.h>
#include <conio.h>
void main ()
{
int a = 10;
do
{
printf("value of a: %d\n", a);
a = a + 1;
}while( a < 20 );
getch();
}
#include<conio.h>
#include<stdio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter table number : \n");
scanf("%d",&b);
for(a=1;a<=10;a++)
{
c=a*b;
printf("%d*",b);
printf("%d=",a);
printf("%d\n",c);
}
getch();
}
#include<conio.h>
#include<stdio.h>
void main()
{
int a,b;
for(a=1;a<=10;a++)
{
for(b=1;b<=a;b++)
{
printf("*",b);
}
printf("\n");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,a,b,c;
for(i=1;i<=8;i++)
{
for(j=8;j>=i;j--)
printf(" ");
for(k=1;k<=i;k++)
printf("*");
printf("\n");
}
getch();
}
#include<stdio.h>
33 | P a g e
#include<conio.h>
void main()
{
int a,b,c,x,y,z;
printf("Enter a number..\n");
scanf("%d",&x);
for(a=1;a<=x;a++)
{
for(y=1;y<=a;y++)
{
printf(" ");
}
for(z=1;z<=a;z++)
{
printf("* ");
}
printf("\n");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
int x[3];
x[0]=10;
x[1]=20;
x[2]=30;
printf("%d",x[0]);
printf("%d",x[1]);
printf("%d",x[2]);
34 | P a g e
getch();
#include<stdio.h>
#include<conio.h>
void main()
{
int x[2][3];
//first row of array
x[0][0]=10;
x[0][1]=20;
x[0][2]=30;
clrscr();
printf("%d",x[0][0]);
printf("%d",x[0][1]);
printf("%d",x[0][2]);
//secon row of array
x[1][0]=40;
x[1][1]=50;
x[1][2]=60;
printf("\n%d",x[1][0]);
printf("%d",x[1][1]);
printf("%d",x[1][2]);
getch();
}
int main()
{
char a[100], b[100];
gets(b);
if (strcmp(a,b) == 0)
{
printf("Entered strings are equal.\n");
}
Else
{
printf("Entered strings are not equal.\n");
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20],b[20];
clrscr();
printf("ENTER 1st THE STRING");
scanf("%s",a);
printf("ENTER 2ndTHE STRING");
scanf("%s",b);
strcat(a,b);
printf("concatenation of string is %s",a);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20],b[20];
int len;
clrscr();
printf("ENTER 1st THE STRING");
36 | P a g e
scanf("%s",&a);
len =strlen(a);
strcpy(b,a);
printf("copy string is %s",b);
printf("lenth of string is %d",len);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20];
clrscr();
printf("ENTER 1st THE STRING");
scanf("%s",&a);
strrev(a);
printf("reverse string is %s",a);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10;
int *p; /*pointer variable*/
p=&a; /*assign memory address of variable */
printf(“address of a =%u”,p);
printf(“value of a =%d”,*p);
getch();
}
#include<stdio.h>
37 | P a g e
#include<conio.h>
void main()
{
int x,*p1,**p2;
x=5;
p1=&x;
p2=&p1;
printf(“x=%d”,x);
printf(“address of x =%u”,&x);
printf(“address of p1=%u”,p1);
printf(“address of p2=%u”,p2);
getch();
}
#include<conio.h>
#include<stdio.h>
float m, n ;
clrscr();
printf ( "\nEnter some number for finding square \n");
scanf ( "%f", &m ) ;
// function call
n = square ( m ) ;
printf ( "\nSquare of the given number %f is %f",m,n );
getch();
}
Assignment- 32 (Structure in c )
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct Books
{
char title[50];
char author[50];
char subject[100];
int book_id;
};
int main( )
{
struct Books Book1; /* Declare Book1 of type Book */
struct Books Book2; /* Declare Book2 of type Book */
clrscr();
/* book 1 specification */
strcpy( Book1.title, "C Programming");
strcpy( Book1.author, "Nuha Ali");
strcpy( Book1.subject, "C Programming Tutorial");
Book1.book_id = 6495407;
/* book 2 specification */
strcpy( Book2.title, "Telecom Billing");
strcpy( Book2.author, "Zara Ali");
strcpy( Book2.subject, "Telecom Billing Tutorial");
Book2.book_id = 6495700;
getch();
}
This is a common problem for beginners because quotes are normally part of a
printf statement. To insert the quote character as part of the output, use the
format specifiers \’ (for single quote), and \” (for double quote).
Which of the following operators is incorrect and why? ( >=, <=, <>, ==)
<> is incorrect. While this operator is correctly interpreted as “not equal to” in
writing conditional statements, it is not the proper operator to be used in C
programming. Instead, the operator != must be used to indicate “not equal to”
condition.
What are header files and what are its uses in C programming?
Header files are also known as library files. They contain two essential things:
the definitions and prototypes of functions being used in a program. Simply put,
commands that you use in C programming are actually functions that are
defined from within each header files. Each header file contains a set of
functions. For example: stdio.h is a header file that contains definition and
prototypes of commands like printf and scanf.
Arrays contain a number of elements, depending on the size you gave it during
variable declaration. Each element is assigned a number from 0 to number of
elements-1. To assign or retrieve the value of a particular element, refer to the
element number. For example: if you have a declaration that says
“intscores[5];”, then you have 5 accessible elements, namely: scores[0],
scores[1], scores[2], scores[3] and scores[4].
Can I use “int” data type to store the value 32768? Why?
No. “int” data type is capable of storing values from -32768 to 32767. To store
32768, you can use “long int” instead. You can also use “unsigned int”,
assuming you don’t intend to store negative values.
Why is it that not all header files are declared in every C program?
The choice of declaring a header file at the top of each C program would depend
on what commands/functions you will be using in that program. Since each
header file contains different function definitions and prototype, you would be
using only those header files that would contain the functions you will need.
Declaring all header files in every program would only increase the overall file
size and load of the program, and is not considered a good programming style.
When storing multiple related data, it is a good idea to use arrays. This is
because arrays are named using only 1 word followed by an element number.
For example: to store the 10 test results of 1 student, one can use 10 different
variable names (grade1, grade2, grade3… grade10). With arrays, only 1 name is
used, the rest are accessible through the index name (grade[0], grade[1],
grade[2]… grade[9]).
What is debugging?
Debugging is the process of identifying errors within a program. During
program compilation, errors that are found will stop the program from executing
completely. At this state, the programmer would look into the possible portions
where the error occurred. Debugging ensures the removal of errors, and plays an
important role in ensuring that the expected program output is met.
What are logical errors and how does it differ from syntax errors?
Program that contains logical errors tend to pass the compilation process, but
the resulting output may not be the expected one. This happens when a wrong
formula was inserted into the code, or a wrong sequence of commands was
performed. Syntax errors, on the other hand, deal with incorrect commands that
are misspelled or not recognized by the compiler.
In C language, the variables NAME, name, and Name are all the same.
TRUE or FALSE?
FALSE. C language is a case sensitive language. Therefore, NAME, name and
Name are three uniquely different variables.
What is the use of a semicolon (;) at the end of every program statement?
It has to do with the parsing process and compilation of the code. A semicolon
acts as a delimiter, so that the compiler knows where each statement ends, and
can proceed to divide the statement into smaller elements for syntax checking.
https://www.programmingsimplified.com/c-program-examples
https://www.programiz.com/c-programming/examples
48 | P a g e