You are on page 1of 6

C Language

C Language was developed by Danis rich in AT & T USA third generation


Language
Low level + High level
Combined system: Hardware prog + Software program
Structure Of C:

# include <Header file list>


Pre processor (or) macros # Define
Global variable declaration
Main ( [argument list] )
{
Local variable declaration
Function body contains statement; control statements, looping, functions, cars,
etc.
Return (value);
}

#include <header file>mean


We will include pre defined files. Header file contains no of functions.
Extension.h
#Macro > Records
Global Variable declaration (outside the block)
Whole nothing but memory space ( (or) identification)
Memory block reserve: we will use variable we can accept the variable throughout our
project (any body can)
Local Variable: with in the block {.}
Main: Main functions to start a program recognize it we must use main.
Argument: parameters.
Function body: contains statement.
Control statement: (flow execution control)
Function cars: if we are writing a program else were if we want to include hear we will
use fun cars.
Rules: each & every statement must be terminated with ( ; )

C Language is a case sensitive & must be typed in lower case letters (small case
letters)
File name will be accepted in 12 characters first 8 character are primary words ninth
character is dot (.) next three character are extension.
DATAT TYPES:

Int (digit) 2 bytes


Float (digit & decimal) 4 bytes
Character (char) 1 byte
Long int 4 bytes
Double 8 bytes
Long double 10 bytes

Variable Declaration rules: variable is a memory block.


Variable name must alphabets
Variable name length is maximum 30 characters.
Without use space characters/special characters must be used only one
word.
Variable name must be unique (it does not support duplicate
names/repetitions)

Declaration Syntax: data type variable name 1, 2, 3.;


Example: int a, b: a & b are integer type of variables. It can store up to 0 to 9
numbers only range of one int is 32,767
Example: float c, d: c & d are floating point variables it can store digits & decimal
places. (0 to 9 & (.) period operators)
Example: char c: c is a char type of variable it can store single char only. Char means
(0 to 255)
Example: char st [10]: st is a char type of variable it can store 10 char continuously.

Input and output function: This function ( ) exists in STDIO.H (standard input &
output) header file. This ( ) displays messages & variable value on the standard
output device (monitor).
Syntax: printf (message, conversion specification characters, new line characters,
variable list);
Example: printf (welcome to C programming);
Conversion specification characters:
Data read/data write in a memory block.

Data type concepts


Int % d, % i
Float %f
Char %c
Long int % ld
Double % lf
String %s
Pointer %p
Address %u
Example: int a;
a=10;
Printf (a value is);
Printf (%d, a);
Or
Printf (a value is %d , a);
Output: a value is 10

Example: float x = 100.98;


Printf (x value is );
Printf (%f, x);
Or
Printf (x value is %f , x);
Output: 100.98

Example: char k= a
Printf (k value is %c, k);
Output: k value is a

New line characters: Function:


\n curser moves to new line
\t curser moves to horizontal tab space

\a beep sound
\b 1 character backspace
\\ inserts the backslash
\? inserts ?
\! inserts !

Write a program to give output?


Pentsoft computers
c/oexecom computers
sriramnagar near bangudi
kakinada
ph 2373206
Main ( )
{
Printf (\n pentasoft computers );
Printf (\n c/o execom computers);
Printf (\n sriramnagar \t near bangudi);
Printf (\n\n kakinada);
Printf (\n\t ph 237306);
}
We can print 80 characters & 25 lines in a common monitor.
HOW TO ENTER INTO C
Go to windows
Select run in start menu
Type command in that box
Press OK
Displays prompt c:\windows \desktop>
Type cd \Tc
Type c: \ Tc\> Tc

Start system
Press f8 button
Select command prompt only in menu
C: \> Tc
C: \ Tc \> Tc

Go to windows
Select c drive
Open Tc folder
Select tc.exe file

Escape
# include <stdio.h>
Main ( )
{
Printf (welcome to c program)
}
To save a program press F2 & give file name
To open a new program Alt F new
Compile (error rectification) F9 Alt+F9
Run Ctrl + F9
Output Alt + F5
New file Alt + &select new
If linker is there we must press F6
Open F3 already existing files (predefined files)

Clrscr ( ); > clears the whole screen & display our answer.
Getch ( ); > instead of pressing Alt + F5 we can use this.
Ctrl F1( ); > displays help.
Clrscr ( ); > this function exits in <conio.h>
<conio.h> > consol input & output
Getch ( ); > this function reads single character from the standard input device
without displaying on the monitor this function also exists in <conio.h> header file.
Write a program take two constant values calculate all arithmetic operation & display the
result?

If the output must be a + b = c

Write a program to accept two no from the keyboard and display?

Write a program to accept radius calculate area of circle and circumference?

Write a program to calculate rectangle area and perimeter?

Write a program to accept two no calculate all arithmetic operation? Use scanf for two
nos?

Write a program accept character display corresponding askey value of the characters?

Write a program and display corresponding character of that number?

Exercise
Write a program to display your address?
Write a program to display your Bio data?

Scanf ( )
This function exits in <stdio.h> header file. This function reads value from the standard
input output device into specified variable.
Syntax: scanf (conversion specification char, variable list);
& = ampersand

You might also like