Programming and logic building-

Programming and logic building-

Introduction of C programming-

  1. C is a general purpose programming language created by Dennis Ritchie at the At&T bell laboratories of the USA in 1972.




  1. It is the most popular computer languages today because it is a structured, high-level, machine independent language.

  2. It allows software developers to develop programs without worrying about the hardware platforms. 

  3. C uses many concepts from these languages and adds the concept of data types and other powerful features. It was developed along with the UNIX operating system. Unix is one of the most popular network operating systems.




Basic syntax in C-

The syntax will be taking the example of print Hello-

#include<stdio.h>

#include<conio.h>

void main()

{

     printf(“Hello”);

}

getch();


Key elements Explained-

  1. #include <studio.h>

           Includes the standard. output library for using printf().

  1. void main()

            The main function is where the execution of the program begins. 

  1. printf(“Hello”)

This prints the text hello, to the screen. 

  1. getch(); 

It is signaling that the program ended successfully.

Loops in C language-

  1. When a block of code needs to be executed several times. In general, statements are executed sequentially. The first statement in a function is executed first, followed by the second and so on.

  2. In other words a loop statement allows us to execute a statement or group of statements multiple times.

There are 2 types of loops-

  1. For loop- It is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. 


The example of for loop is-

#include<studio.h>

#include<conio.h>

void main()

{

      int i=1;

      for(i=1;i<=5;i++)

      {

           printf(“%d\n”, i);

      }

  getch();

}

  1. While loop- A while loop in C programming repeatedly executes a target statement as long as a given condition is true. It is an entry controlled loop statement. Also known as pre test loop.


The example of while loop is-


#include<stdio.h>

#include<conio.h>

void main()

{

      int i=1;

      while(i<=5)

      {

          printf(“%d\n”, i);

             i++;

      }

     getch();

}

  1. Do while loop- unlike for and while loops, which test the loop condition at the top of the loop, the do while loop in C programming checks it's condition at the bottom of the loop. A do while is similar to a while loop, Except the fact that it is guaranteed to execute at least one time. 


The example of do while loop is-

#include<stdio.h>

#include<conio.h>

void main()

{

     int i=6;

     do

     {

         Printf(“%d\n”, i);

             i++;

     }while(i<=8);

  getch();

}


Functions in C language -

Function is a self-contained block of code that confirms a particular task. 

In other words it is a group of statements that together perform a task. Every C program has at least one function. Which is main(), and all the most trivial programs can define additional functions.


Function can be classified into two categories-

  1. In-built/Library function.

  2. User-defined function. 


The example of In-built functions is printf,scanf. 

The main distinction between these two categories is that Library functions are not required to be written by us whereas a user defined function has to be developed by the user at the time of writing a program.

Hence a user defined function can become a part of the c library.


How to declare a function-

  1. A function declaration tells the compiler about a function’s name, return type and parameters. A function definition provides the actual body of the function. The actual body of the function can be defined separately.

  2. Function declaration is required when you define a function in one source file and you call that function in another file. In such case, you should declare the function at the top of the file calling the function.


Taking one program of function as a example -

#include <stdio.h>


int square(int x) { return x * x; }

int sum(int a, int b) { return square(a) + square(b); }


int main() {

    int x = 2, y = 3;

    printf("%d", sum(x, y));

    return 0;

}


What is python?

Python is a general purpose, dynamically, high level language developed by “Guido van Rossum” in the year 1991 in CWI(centrum wiskunde & information) Netherland.

Guido van Rossum was a fan of the popular comedy show “Monty python's flying circus” 

Broadcasted by BBC (1964-74). So he decided to name his language as a python.

Syntax- print(“Hello”);



Features of python are-

  1. Simply & easy to run.

  2. Freeware & open source.

  3. Platform independent.

  4. Rich library.

  5. Portable.

  6. Embedded.

  7. Extensible.

  8. Interpreted.


Application of python-

  1. Web development.

  2. Game development.

  3. IOT programming.

  4. Machine learning.

  5. Artificial intelligence(AI)

  6. Database management programming.

  7. Network programming.


There are some limitations of python also-

  1. Mobile application.

  2. Performance up to the mark.


Example of python print hello world?

print("Hello, World!")

⚠️
Mobile Access Required
This website is optimized for mobile devices only.
Please open this page on your smartphone or tablet for the best experience.