1 / 12

Programming Paradigms

Programming Paradigms. Lecturer Hamza Azeem. Lecture 3. C Building Blocks - II. Example of Scanf (). int main() { long years, days; printf ( “Please type your age in years: "); scanf ( “%ld", &years); days = years * 365; printf ( "You are %ld days old", days); }. Output of Example.

rae-deleon
Télécharger la présentation

Programming Paradigms

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. Programming Paradigms LecturerHamza Azeem

  2. Lecture 3 C Building Blocks - II

  3. Example of Scanf() • int main() • { • long years, days; • printf( “Please type your age in years: "); • scanf( “%ld", &years); • days = years * 365; • printf( "You are %ld days old", days); • }

  4. Output of Example Please type your age in years: 25 You are 9125 days old

  5. Address Operator (&) • Scanf() function requires the address of the variable where to put the value obtained. Rather than the variable itself. • The & operator provides the address of the memory location where a variable is stored

  6. GETCH() Function • Getch() is only used for taking character input • It only takes one character • Once types the character can’t be erased • No need for pressing enter key

  7. Example of GETCH() • int main() • { • char ch; • printf("Type any character:"); • ch=getch(); • printf("\n The character you typed: %c",ch); • }

  8. How to display variables on Output ? • C Language uses 4 types of Arithmetic Operators common in most programming. + Addition - Subtraction * Multiplication / Division % Remainder

  9. Remainder Operator • It is also called Modulo Operator • Example19 % 5 = 4

  10. Arithmetic Assignment Operators

  11. Increment/Decrement Operator

  12. Relational Operators

More Related