Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals of Computer and programming in C Programming Languages, Programs and Programming Rohit Khokher.

Similar presentations


Presentation on theme: "Fundamentals of Computer and programming in C Programming Languages, Programs and Programming Rohit Khokher."— Presentation transcript:

1 Fundamentals of Computer and programming in C Programming Languages, Programs and Programming Rohit Khokher

2 Concepts: Programming Languages, Programs and Programming Programs A set of statements written in a Programming Language and arranged in a specified structure. Executable Non-executable Machine Assembly High level Main programs Sub-programs 1011001011001110111010 ADDAB A+B Operation code Operand

3 Executable statements Non-executable statement Declarations (definitions) Data type declarations o integer data type. o Floating point data type. o Character data type. Variable declarations Constant declarations Program type declarations o Main program o Subprogram Perform Arithmetic operations Logical operations Transfer execution control operations Cause iteration Data movement operations o Input devices to memory o Memory to output devices o Memory to memory o Memory to register o Register to memory

4 Structures The structure of a main program in C language Preprocessor declarations Type declarations Variable declarations (global) void main () { local declarations Executable statements } Function (subprogram) declarations #include void main () { printf (“ \n I am in the main program”); } Stdio.h is a collection of subprograms for input and output operations like printf (). No declaration (empty) Main is an address in the memory. It may contain a data. Void indicates the type of the data will be determined when it will contain a data value. No declaration (empty)

5 #include void main () void main () { printf (“ \n I am in the main program”); } Code Segment Data Segment Iaminthemmainprogram Compiler  Checks the syntax  Generates codes Compiler  Checks the syntax  Generates codes Loader/ Linker/ Binder Loads Loader/ Linker/ Binder Loads Data in Data segment Code in code segment main Stdio.h Printf Data address PC Compilation & execution of a program

6 Algorithm Example Suppose you are given a set of mark sheets where each mark sheet bears A, B, C or F letter grade. Write an algorithm to read mark sheet and print the grade that it contains. 1.Start 2.Take a mark sheet and read the grade. 3.Print the grade 4.Stop #include void main() { char c; printf ("\n enter the letter grade "); c=getchar(); printf ("\n Grade= "); putchar(c); gets(""); } #include void main() { char c; printf ("\n enter the letter grade "); c=getchar(); printf ("\n Grade= "); putchar(c); gets(""); }

7 Algorithm Example 2 Suppose you are given a set of mark sheets where each mark sheet bears A, B, C or F grade. Write an algorithm to read a mark sheet and print if the grade is A only. 1.Start 2.Take a mark sheet and read the grade. 3.If grade is A then Print the grade 4.Stop #include void main() { // reading and writing characters char c; printf ("\n enter the letter grade"); c=getchar(); if( c =='A') { printf("\n The grade is = "); putchar(c); } #include void main() { // reading and writing characters char c; printf ("\n enter the letter grade"); c=getchar(); if( c =='A') { printf("\n The grade is = "); putchar(c); } }

8 Algorithm Example 3 Suppose you are given a set of mark sheets where each mark sheet bears A, B, C or F grade. Write an algorithm to read a mark sheet and print the grade if it is A or B only. 1.Start 2.Take a mark sheet and read the grade. 3.If grade is A or B then Print the grade 4.Stop #include void main() { // reading and writing characters char c; printf ("\n enter the letter grade"); c=getchar(); If (( c =='A') | ( c =='B')) { printf("\n The grade is = "); putchar(c); } #include void main() { // reading and writing characters char c; printf ("\n enter the letter grade"); c=getchar(); If (( c =='A') | ( c =='B')) { printf("\n The grade is = "); putchar(c); } }

9 Summary Program – Main program – Subprogram Statements – Executable – Non executable Programming Language – Machine Language – Assembly Language – High level Language Structure Main program Subprograms (functions) Blocks Compilers Loaders Linkers Interpreter s


Download ppt "Fundamentals of Computer and programming in C Programming Languages, Programs and Programming Rohit Khokher."

Similar presentations


Ads by Google