C - Notes - Upto Loops
C - Notes - Upto Loops
C - Notes - Upto Loops
-> C is a general-purpose programming language, developed in 1972, and still quite popular. C is
very powerful; it has been used to develop operating systems, databases, applications, etc..
-> C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories
in 1972.It is a very popular language, despite being old.C is strongly associated with UNIX, as it was
developed to write the UNIX operating system.
Compiler:
The source code written in source file is the human readable source for your program. It needs
to be "compiled", into machine language so that your CPU can actually execute the program
as per the instructions given.The compiler compiles the source codes into final executable
programs.
A compiler is a special program that translates a programming language's source code into
machine code, bytecode or another programming language.
Sample C program:
#include <stdio.h>
int main(){
printf("Hey There");
return 0;
}
The printf() and scanf() functions are used for input and output in C language. Both functions
are inbuilt library functions, defined in stdio.h (header file).
return 0 The return 0 statement, returns execution status to the OS. The 0 value is used for
successful execution and 1 for unsuccessful execution.
Constant:- A constant is a value or variable that can't be changed in the program, for example:
10, 20, 'a', 3.4, "c programming" etc.
VARIABLES:
A variable is a name of the memory location. It is used to store data. Its value can be
changed, and it can be reused many times.
It is a way to represent memory location through symbol so that it can be easily identified.
Data types :
Keywords in C
A keyword is a reserved word. You cannot use it as a variable name, constant name, etc.
There are only 32 reserved words (keywords) in the C language.
Identifier:- We can say that an identifier is a collection of alphanumeric characters that begins
either with an alphabetical character or an underscore, which are used to represent various
programming elements such as variables, functions, arrays, structures, unions, labels, etc.
Format Specifier:- The Format specifier is a string used in the formatted input and output
functions. The format string determines the format of the input and output. The format string
always starts with a '%' character.
-> Compile-time and Runtime are the two programming terms used in the software
development. Compile-time is the time at which the source code is converted into an
executable code while the run time is the time at which the executable code is started running.
Operators in C:
Conditional Statements:
The if-else statement in C is used to perform the operations based on some specific condition.
The operations specified in if block are executed if and only if the given condition is true.
o If statement
o If-else statement
o If else-if ladder
o Nested if
Looping Statements:
The looping can be defined as repeating the same process multiple times until a specific
condition satisfies. There are three types of loops used in the C language.
1. for
2. while
3. Do while
Break :- The break is a keyword in C which is used to bring the program control out of the
loop. The break statement is used inside loops or switch statement. The break statement
breaks the loop one by one, i.e., in the case of nested loops, it breaks the inner loop first and
then proceeds to outer loops. The break statement in C can be used in the following two
scenarios:
1. With switch case
2. With loop
Continue:- The continue statement in C language is used to bring the program control to the
beginning of the loop. The continue statement skips some lines of code inside the loop and
continues with the next iteration. It is mainly used for a condition so that we can skip some
code for a particular condition.