×
ALL THE HUSTLE, LATE NIGHTS, MISSED PARTIES, EARLY MORNINGS WILL BE WORTH IT.

# Note for Programming in C - C by Ashutosh Jaiswal

• Programming in C - C
• Note
• 14 Views
0 User(s)

#### Text from page-2

Algorithm: Step by step procedure of solving a particular problem. Pseudo code: Artificial informal language used to develop algorithms. Flow chart: Graphical representation of an algorithm. Algorithm to find whether a number even or odd: Step1: Begin Step1: START Step2: Take a number Step2: Read num Step3: if the number is divisible by2 then Step3: if(num%2=0) then print that number is even print num is even otherwise print that number is odd otherwise print num is odd Step4: End Step4: STOP (Algorithm in natural language) (Algorithm by using pseudo code) #include<stdio.h> #include<conio.h> main() { int num; printf(“Enter any number”); scanf(“%d”,&num); if(num%2==0) printf(“%d is even”,num); else printf(%d is odd”,num); } (Program in C language) start Flow chart: read num Yes If num%2=0 No print num is odd print num is even stop

#### Text from page-3

Flow chart symbols Oval Terminal Parallegram Input/output Rectangle Process Document Hard copy Diamond Decision Circle Connector Double sided Rectangle Sub program Hexagon Iteration Trapezoid Manual Operation Cylinder Magnetic Disk Storage

#### Text from page-4

Machine Language – Assembly Language – High-Level Language 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 9 1 0 00000000 00000100 0000000000000000 01011110 00001100 11000010 0000000000000010 11101111 00010110 0000000000000101 11101111 10111110 0000000000001011 11111000 10101101 11011111 0000000000010010 01100010 11011111 0000000000010101 11101111 00000010 11111011 0000000000010111 11110100 10101101 11011111 0000000000011110 00000011 10100010 11011111 0000000000100001 11101111 00000010 11011111 0000000000100100 01111110 11110100 10101101 11111000 10101110 11000101 0000000000101011 00000110 10100010 11111011 0000000000110001 11101111 00000010 11111011 0000000000110100 01010000 11010100 0000000000111011 00000100 0000000000111101 #include<stdio.h> int main(void) { int n1, n2,product; printf(“Enter two numbers : “); scanf(“%d %d”,&n1,&n2); product = n1 * n2; printf(“%d”,product); return 0; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 entry main,^m<r2> sub12 #12,sp jsb C\$MAIN_ARGS moveb \$CHAR_STRING_CON pusha1 pusha1 calls pusha1 pusha1 calls mull3 pusha calls clrl ret -8(fp) (r2) #2,SCANF -12(fp) 3(r2) #2,SCANF -8(fp),-12(fp),6(fp) #2,PRINTF r0 The only language the computer can understand is machine language (binary language). A high level language is an English like language where one instruction typically translates into a series of machinelanguage instructions. A low level language corresponds closely to machine code so that a single low-level language instruction translates to a single machine language instruction.

#### Text from page-5

Structure of C program /*Program to find area and perimeter of Circle */ #include<stdio.h> #define PI 3.1415 float radius; float area(); float perimeter(); int main() { float a, p; printf(“Enter radius : “); scanf(“%f”,&radius); a = area(); p = perimeter(); printf(“Area of Circle : %f”,a); printf(“Perimeter : %f”,p); } float area() { return (PI * radius * radius); } float perimeter() { return (2 * PI * radius); } Documentation Section Linkage Section Definition Section Global Declaration Section Main Function Section Local Declaration Part Executable Code Part Sub Program Section Function1() Function2() …………… FunctionN()