C programming


Learn C with HYTEK



What is C programming ?

C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on. C programming is an excellent language to learn to program for beginners.

FAQ ??

1 what is programming why we need programming ?

2 Uses of programming ?

What Softwares Require in C  Programming ?

For writing program in C You need Two Major Software.

1 Code Editor

There are many Code Editor available on Internet It’s your which one you want to use we recommend VS-Code Editor.Because it is free and the community is so big and very user friendly interface.. but Again it’s Up to You..

2 Compiler

A program that converts instructions into a machine-code or lower-level form so that they can be read and executed by a computer.”conversion would require more than just running it through a different compiler”

On internet various Compiler are available You Can install Any of them But we recommend GCC-COMPILER.. It’s used by many c experts and many C Programming experts also recommend to use this compiler but Again you don’t have to woried about this use which one you want to use..

Visual Studio Code is a free source-code editor made by Microsoft for Windows, Linux and macOS. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git.

The GNU Compiler Collection is an optimizing compiler produced by the GNU Project supporting various programming languages, hardware architectures and operating systems. The Free Software Foundation distributes GCC as free software under the GNU General Public License.

CHAPTER – 1

Definition :: what is C ?

C is a programming language. c is one of the oldest and finest programming languages,C was developed by Denis Ritchie at AT & T’s Bell USA 1972

USES OF C PROGRAMMING

Clanguage is used to program a wide variety of system some of the uses of c are as follows

1.major parts of Windows, linux and other operating systems are written in c.

2.C is used to write driver programs for devices like tablet , printers etc.

3. C language is used to program embedded systems where programs need to run faster in limited mamory (microwave,cameras)

4.C is used to develop games and area where latency is very important ie: computer has to react quickly on user input

Chater 1

variables, Constants & Keywords

VARIABLES

A variables is a container which stores a value.

for example//

a = 3; b = 4.5;

// a is assigned 3 // b is assigned 4.5

There are some rules for naming variables in C

  1. First character must be an alphabet or underscore( _ )
  2. No commas ( , ) blanks allowed
  3. No special character other than underscore allowed
  4. Variables name are case sensative

Constants

An entity whose value does not change is called as a constant . A variable is an entity whose value can be changed

Types of constants

There are three types of constants

  1. Integer constant \\ 1 2 3, -1 -2 -3
  2. Real constant \\ -33.3,2.5,7.0
  3. Character constant \\ ‘a’, ‘$’,’@'(must be enclosed within single inverted commas)

Keywords

These are reserved words whose meaning is already known to the compiler There are 32 keywords avaliable in C

autodoubleintstruct
breaklongelseswitch
casereturnenumtypedef
charregisterexternunion
constshortfloatunsigned
continuesignedforvoid
defaultsizeofgotovolatile
dostaticifwhile

our First C Program

#include
int main (){
printf(“Hello i am learning C with HYTEK”);
return 0;
}

Basic structure of a C program

All C program have to follow a basic structure of C program starts with the main function and executes instruction present inside it

Each instruction is terminated with a semicolon ( ; )

There are some rules which are applicable to all the C programs

  1. Every program execution starts from main ( ) function.
  2. All statements are terminated with a semicolon
  3. Instructions are case sensitive
  4. Instructions are executed in the same order in which they are written

Comments

Comments are used to clarify something about the program in plain language it is the way for us to add notes to program there are two types of comments in C

  • Single line comment : // this is a comment
  • Multi line comment : /* This is a multi line comment*/

Comments in a C program are not executed and are ignored by the compiler

A compiler is a computer program which converts a C program into machine language so that it can be easily understood by the computer

A C  program is written in plain text
This plain text is a combination  of instruction in a particular sequence the compiler perform some basic checks and finally converts the program into an executable code

Library Function

C language has a lot of valuable library function which is used to carry out certain task for instant (printf) function is used to print values on the screen

Printf("this is %d",i);

%d for integers
%f for real values
%c for characters

Types of variables

  1. Integer variables // int a = 3;
  2. Real variables     // float a = 5.5;
  3. Character variables  // char a = ‘@’;

Receiving input from the user

In order to take input from the user and assign it to a variable we use//  scanf // function

Syntex for scanf function

scanf(“%d”,&a);//& is important because this is used for address for storing variables.

& is the “address of ” operator and it means that the supplied value should be copied to the address which is indicated by variables


Basic C programming code Example

// Hello world example

#include<stdio.h>  
                                                                   main()
{

printf(“Hello World”);

}

Output:

Hello World


// simple printf example

#include <stdio.h>

main()
{

printf(“\tMy Introduction\n”);
printf(“Hey Friends I m Ram\n”);
printf(“I m student of HYTEK.com”);
printf(“\nC programming is best for me.”);
printf(“\t”);

}

\n is used for print new line
\t is used for print new tab (space)

Printf is used for print output on screen

Output: My Introduction
Hey Friends I m Ram

I m student of HYTEK.com

C programming is best for me.