1 / 9

Fundamentals of Computer and programming in C

Fundamentals of Computer and programming in C. Programming Languages, Programs and Programming Rohit Khokher. Concepts: Programming Languages, Programs and Programming. Executable. Operation code. Operand. Non-executable.

yen
Download Presentation

Fundamentals of Computer and programming in C

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fundamentals of Computer and programming in C Programming Languages, Programs and Programming RohitKhokher

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

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

  4. Structures The structure of a main program in C language Stdio.h is a collection of subprograms for input and output operations like printf (). Preprocessor declarations #include <stdio.h> Type declarations Variable declarations (global) 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. void main () { local declarations Executable statements } void main () { printf (“ \n I am in the main program”); } Function (subprogram) declarations No declaration (empty)

  5. #include <stdio.h> void main () void main () { printf (“ \n I am in the main program”); } PC Code Segment Data address Stdio.h Loader/ Linker/ Binder Loads Codeincodesegment main Printf • Compiler • Checks the syntax • Generates codes DatainDatasegment Data Segment

  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. • Start • Take a mark sheet and read the grade. • Print the grade • Stop #include <stdio.h> 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. • Start • Take a mark sheet and read the grade. • If grade is A then Print the grade • Stop #include <stdio.h> 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. • Start • Take a mark sheet and read the grade. • If grade is A or B then Print the grade • Stop #include <stdio.h> 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 • Structure • Main program • Subprograms (functions) • Blocks • Compilers • Loaders • Linkers • Interpreter s • Program • Main program • Subprogram • Statements • Executable • Non executable • Programming Language • Machine Language • Assembly Language • High level Language

More Related