Input and Output programs
This section contains example programs demonstrating the input and output functions.
This program uses the scanf function.
#include
main() { float a , b , c; printf("Input two numbers... \n"); scanf("%f%f" , &a , &b); c = a * b ; printf("%f times %f = %f\n" , a , b , c); }
This program combines printf and scanf whereby printf displays the input from scanf.
#include
main() { int i; printf("%c\n",scanf("%i",i)); }
This program demonstrates the use of getchar and putchar.
#include
main() { char ch;
printf("Enter some text (type a period to quit)...\n");
do { ch = getchar(); putchar(ch+1); } while (ch != '.');
printf("\n\n");
printf("Enter some text (type a period to quit)...\n"); while ( (ch = getchar()) != '.') putchar(ch-1);
printf("\n\n"); }
|
No responses found. Be the first to respond and make money from revenue sharing program.
|