Sunday
Operators
Operator: (LARACIBUS)
Logical operators: (B)
Arithmetic operators: (B)
Relational operators: (B)
Assignment operators: (B)
Conditional operators: (T)
Increment and decrement operators: (U)
Bitwise operators: (B)
Special operators:
Unary(U): operator has only one operand.
Syntax:
<operator> <operand>;
or
<operand> <operator>;
Binary(B): operator has two operands.
Syntax:
<operand1> operator <operand2>;
Ternary(T): operator has three operands.
Syntax:
<Variable> = <(condition)>? <true part of condition> :
<false part of condition>;
Saturday
printf & scanf Statement
printf : It is use to print any message or value of any variable.
Syntax:
printf("message");
or
printf("message <control_string>",variable);
Where.....
<control_string>
Message: Message that you want to print on console.
Variable: Variable name which value you want to print.
scanf : It is use to read value of variable from user(console).
Syntax:
scanf("message <control_string>”,&variable1,&variable2,...&variable);
Sunday
how to get value from user or console and print it on console?
Scan and Print value of Variable
File Name: "file_name.c"
Code:
void main()
{
int a;
clrscr();
printf("enter a value of a:");
scanf("%d",&a); //scan the value of a from console
printf("value of a =%d",a);
}
Output:
Variable & Data Type
Variable: A variable is a data name that may be used to store a data value.
Primary data_type:
Syntax:
<data_type> <variable _name>; //declaration
or
<data_type> <variable_name> = <Value>; //declaration & assignment
User define data_type:
typedef: “type definition” allows to users to define an identifier that would represent an existing data_type.
Syntax:
typedef <data_type> <identifier>;
enum: “enumerated” data_type allows declaring variables that can have one of the values enclosed within the braces (known as “enumeration”).
Syntax:
enum <identifier> {Value1, Value2, Value3, ...ValueN};
<data_type>:
<variable_name>:
- Variable name must be beginning with the letter.Some systems permit underscore (“_”) as the first character.
- ANSI standard recognize a length of 31 characters. But length should not be more than 8 characters, since only first 8 characters are treated as significant by compiler (C99 supports 63 characters).
- Uppercase and lowercase are distinguished.
- Variable name should not be a “keyword”
- “White space” is not allowed.
Simple program
printf Statement
File Name:"file_name.c"
Code:
void main()
{
printf("Hello !!!");
}
Output:
Saturday
Basic Structure of c program
Documentation Section: - It includes a comment statement that gives detail information about program.
Linking Section: - It provide introduction to compiler about linked functions and included library files (header files).
Definition Section: - Define all symbolic constant.
Global Declaration Section: - Variables that are declared globally which are available in all function in program.
Main () function Section: - Every c program has only one main function in which program code is written and it content two parts.
Note: By default return type of main function is “int”.
Declaration Part: - All variables must be declared before it used or executable part.
Execution part: - Executable code should be written in this section. There should be at least one statement in this part which contains instructions to perform given task.
Note:
-
The declaration and executable part must be written in between the opening and closing braces.
-
All statements in the declaration part must end with the semicolon.
-
C is a case sensitive programming language. It means in C printf and Printf will have different meanings.
-
C has a free-form line structure.
-
Multiple statements can be one the same line.
-
White Spaces (ie tab space and space bar ) are ignored.
Sub program Section: - It contents all user define functions which are called in main function.
Sunday
Introduction to C language
C is a general-purpose high level language that was originally developed by Dennis Ritchie for the Unix operating system. It was first implemented on the Digital Equipment Corporation PDP-11 computer in 1972.
• Simple and Easy to learn
• Structured language
• It procedure oriented programing language
• It can handle low-level activities.
• It can be compiled on a different type of computers.
• It is platform depended language.
Facts about C
• UNIX operating system was written in C language
• C is a modified language of B which was introduced around 1970
• The language was formalized in 1988 by the American National Standard Institue (ANSI).
• Unix Os was almost written in C by 1973.
• Nowadays C is widely used System Programming Language.
• Most of the state of the art software have been implemented using C like google,adobe system,mozila,etc..
Why to use C ?
Applications of C Language:
• Operating Systems
• Text Editors
• Language Compilers
• Print Spoilers
• Language Interpreters
• Network Drivers
• Modern Programs
• Assemblers
• Utilities
• Data Bases
Program File
All the C programs are written into text files with extension ".c" for example "file_name.c". You can use "vi" or “turbo C” editor to write your C program into a file.
Compilers
When you write any program in C language then to run that program you need to compile that program using a C Compiler which converts your program into a language understandable by a computer. This is called machine language (ie. binary format). So before proceeding, make sure you have C Compiler available at your computer. It comes alongwith all flavors of Unix and Linux.
Click this link and download turbo C