Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

COMMON FORMAT—

#include<stdio.h>
Int main() {

YOUR CODE

return 0;
}
C-Language
Chapter-1…
To compile any C code, we first open terminal and then
we write c language compiler which is “gcc _space_ File
name”
Then to run any C code “./a.exe --- For windows”
“./a.out ----- For Mac/Linux”
Variables- Variable is the name of a memory location
which stores some data.
Rules-
• Variables are case sensitive.
o a and A are different….
• 1st Character is alphabet or ‘_’
• No comma/blank space.
• No other symbol than ‘_’
Constants- Values that don’t change (fixed).
Compilation-A computer program that translates C code
into machine code.
Que-Write a program to calculate area of square.
(Side given)

Used in every c code


Used for decimal value

Here its used for


entering the Here it prints answer
value of side
needed

Used in every c code


#We will use %f for getting answers in decimal
value…
Que- Write a program to calculate area of a
circle? (radius is given)
Used for getting result
in decimal value

QUE- Perimeter of rectangle?


Chapter-2…
Conversion
1. Implicit conversion – Conversion that is done
by the system itself…
Example- Int to Float
2. Explicit conversion – Conversion which is
done/directed by us to system…
Example – DIRECTED
CODE—

RESULT-
#In C code the compiler removes every number
after point if the function is not is not in
float, it doesn’t take any approx. For
example, in above code the 1.999999 was
converted into 1.

#1.99999 was a float value but 1 is Int


value, this conversion was not possible by
implicit conversion but after we directed the
conversion it was possible.

# OPERATOR PRESCEDENCE
*,/,%

+ , -

!,*,/,%,<,<=,>,>=,==,!=,&&,||,=
Que-Write a program to check if a number is
divisible by 2 or not.
CHAPTER-3
If-else
If(condition) {
//do something if true
}
Else if (condition 2) {
//do something if 1st false and 2nd is true
}
else {
//do something if false
}

You might also like