Showing posts with label C Programming. Show all posts
Showing posts with label C Programming. Show all posts

Tuesday 6 February 2024

DataTypes

 Each variable in C has an associated data type. It specifies the type of data that the variable can store like integer, character, floating, double, etc. Each data type requires different amounts of memory and has some specific operations which can be performed over it. The data type is a collection of data with values having fixed values, meaning as well as its

Thursday 1 February 2024

Introduction of Programming Languages

Introduction of Programming Languages

Points to be covered in this are as follows:


1.1 Types of Languages
1.2 Evolution of 'C' Language
1.3 Structure of a 'C' Program
1.4 'C' Program Development life cycle
1.5 Executing & Debugging a 'C' Program.


What is Computer?

  • A computer is an electronic device that can be instructed to do sequences of arithmetic (+, -, *, /) or logical (&&, ||, !) operations via computer programming.


What is Computer Program?

In simple term computer program is nothing but set of instructions (group of small units of instructions) that computer can compile or interpreter and execute it for the required result.

What is Compiler or Interpreter?

Compiler and Interpreter both are software programs do the same task that is conversion of High-level Languages (Human Understandable) into Machine Level Language (Computer Understandable).

But there is a little bit difference at the time of conversion of HLL into MLL. Compiler take entire program and translates whole into machine language. Whereas Interpreter translates one line at a time. Compiler generates object code interpreter does not generate object code hence it is memory efficient.

Programming Languages uses interpreter are Ruby, JavaScript, Python. Programming Languages uses compiler are C, C++ and Java. 

What is Computer Programming Language?

We all know very well that we use Languages to communicate with each other. So, what if we want to communicate with Computer which is an electronic device so we must communicate in a language which machine understand and as we all know machine understand only low-level language that is 0 and 1. but as a human being it is impossible for all of us to keep that 0 and 1 in mind for communication.
To overcome this limitation here comes a high-level language which human can understand but machine cannot. To make it machine understandable we use compiler and interpreter to convert this HLL into MLL.

Who is Computer Programmer?

Anyone who write set of instructions in high level or Assembly level language to execute specific task. that set of instructions are called as Source code or Program.

Who was the world's first Computer Programmer?

World first computer program written by Lady Ada Lovelace in the year of 1842. Charles Babbage and Ada Lovelace developed the first computer analytical engine. She wrote the first computer program in Ada Programming language. She was English mathematician and writer.
Example: Ada Program to find the Total of two Whole numbers.

Program:

With Gnat.IO; use Gnat.IO;
procedure addtwowholenumber is
    no1 : Integer;
    no2 : Integer;
    Total : Integer;
begin
    Put ("Enter value of no1: ");
    Get (no1);
    Put ("Enter value of no2: ");
    Get (no2);
    Total := no1 + no2;
    Put_Line ("Total= " & integer'image(Total));
end;
Output:
$ gnat make addtwowholenumber.adb
gcc -c addtwowholenumber.adb
gnatbind -x addtwowholenumber.ali
gnatlink addtwowholenumber.ali
$ ./addtwowholenumber
Enter value of no1: 5 Enter value of no2: 4 Total = 9

1.1 Types of Languages

(C, C++, Pascal)
High Level Languages
||
Assembly Level Language
||
Machine Level Language or Low-Level Language
||
Hardware

Tuesday 26 September 2023

Pointer to Function Concept in detail with example

 Pointer to Function:

Like built in variables function also contains address.

How to declare function pointer?
return type (*fp)( );  // in this way you have to declare function pointer to hold the address of function.
void add( );


void (*fp) ( );  // declaration of function pointer to hold the address of function add();


fp=add;


so you can call add() function like (*fp)( );