1 / 8

Chapter 4: Data Input Output

Chapter 4: Data Input Output. Dr. Ameer Ali. Single Character Input/Output. Single character can be entered char c; c=getchar(); Single character output putchar(c);. Entering Input Data. scanf(control string, arg1, arg2,…,argn); scanf(“%d”, &variable);. More About scanf.

napua
Télécharger la présentation

Chapter 4: Data Input Output

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. Chapter 4: Data Input Output Dr. Ameer Ali

  2. Single Character Input/Output • Single character can be entered • char c; c=getchar(); • Single character output • putchar(c);

  3. Entering Input Data • scanf(control string, arg1, arg2,…,argn); • scanf(“%d”, &variable);

  4. More About scanf • scanf(“%3d %3d %d”, &a, &b, &c); • scan(“%3hd %7lx %15lf”, &ix, &lx, &dx);

  5. Writing Output Data • printf(control string, arg1, arg2, …, argn); • printf(“%s %d %f”, item, partno, cost); • printf(“%12s %.3d %.5f”, item, partno, cost);

  6. gets and puts • char line[80]; • gets(line); • puts(line);

  7. Example • Calculating exam scores • #include <stdio.h> main() { char name[20]; float score1, score2, score3, score4; printf(“enter your name”); scanf(“%s”, name); printf(“enter your first score”); scanf(“%f”, &score1); printf(“enter your second score”); scanf(“%f”, &score2); getch(); }

More Related