CODEXCEL Tutorial 01 - Introduction to C Programming

   



CODEXCEL Tutorial 01 - Introduction to C Programming




 In the field of programming, an issue can have more than one solution. Programmers may output the same result by coding the program in different ways by using various programming languages,leading it to different code solutions.
    This blog post's key goal is to demonstrate how to use the C programming language to determine the output of a program and to program various creative shapes while additionally exploring how to get the same result for a problem with different code.
    Before moving on to the discussion let's talk about some important and basic points in C language:
  • C language is a case sensitive language and not an object oriented language.
                    Example - NUM , Num, num are three different variables
  • It is compulsory to add a semi-colon (;) at the end of each and every statement.If it doesn't end with a semi-colon, an error message appear.
  • The compiler ignores the white spaces in the code. Therefore,writing the code by using multiple line makes it much more readable.

Let's Start Coding

    To begin with, we must write our code using an IDE. An Integrated Development Environment (IDE) is a single integrated application used for editing, compiling, running, and debugging programs. Of all the IDEs available, Quincy 2005 is the one we will be using. 

 Here's where I'll continue the Q&A-formatted explanation. You ought to find it simpler to read and comprehend this post as a result.

Question 1 : Write a program that prints the following text at the terminal. 

 • In C, lowercase letters are significant. 
 • main is where program execution begins. 
 • Opening and closing braces enclose program statements in a routine. 
 • All program statements must be terminated by a semicolon.

To get the above output first, you need to open Quincy 2005 IDE and create a C source file and save it with ".c" extension.Next you can code the program as shown below.

 Now let's see the explained breakdown of the above code.

#include<stdio.h>

Including the standard input output header file (stdio.h) in the program is instructed by this to the compiler.Header file files add functionality to C programs.

int main() {}

int - Represent the type of data of the out coming result.
main() - Name of the program and indicate where to begin the execution of the program.In some occasions different arguments are used in between the parenthesis.
{} - Displays the beginning and end of the statements that make up the main function.Every statement enclosed in parenthesis is a component of the primary function.

printf("In C,lowercase letters are significant.\n");

An output representing keyword in the C programming language. Parenthesis are used following the call to printf().All text contained in double quotes will be shown,with the exception of " \n". 
  • \t represents the 'tab' key in the keyboard.
  • \n means a new line.It represents the 'enter' key in the keyboard. 

return 0;

Main function ends with the use of this.This indicates that the program ran error-free and successfully.Any integer value can be used in this place in place of  0.The program will not be impacted.However, we typically use "0".

Output of the above program will be as follows;



Question 02 : Print the following shapes.


 This how the output of the above question will be.I will display all six shapes in a single program rather than showcasing them individually.

Question 03: Print your curriculum vitae.


Now let's see the breakdown of the above program.
First as explained in question 01 #include<stdio.h> includes the standard input output header file (stdio.h) in the program is instructed by this to the compiler.Next int main(){} represent the data type of the result and main() says the compiler where to begin to execute the program.Opened and closed curly braces reserve a particular space to the code.
Furthermore,printf() prints the statement with the double quotes except '\n' and '\t'.

According to the above C program the final output is as follows;
 




Question 04 : What output would you expect from the following program?

The output is;

In hope now you have a good understanding of how to write C programs.

So let's wrap up today's post and get together again for some more exercises to enhance our C handling.Enjoy your pleasant day!

Contribution : Question 01- Parami Ashinsa (ICT/2022/067)
                        Question 02/04 - R.M.M.N.Rathnayake(ICT/2022/087)
                        Question 03 - Shirani Aberathna(ICT/2022/098)


Comments

Popular Posts