Advertisement
DrAungWinHtut

basicIO.c

Feb 8th, 2023
898
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     //storage
  5.     printf("First Values\n");
  6.     printf("===========\n");
  7.     int i = 10;
  8.     float f = 33.4;
  9.     char ch = 'a';
  10.     printf("i=%d\n", i);
  11.     printf("f=%f\n", f);
  12.     printf("ch=%c - %d\n", ch,ch);
  13.     printf("Second Values\n");
  14.     printf("===========\n");
  15.     i = 20;
  16.     f = 55.6;
  17.     ch = 'k';
  18.     printf("i=%d\n", i);
  19.     printf("f=%f\n", f);
  20.     printf("ch=%c - %d\n", ch, ch);
  21.     //processing arithmetic operation + - * / % , logical operation > < == !=
  22.     printf("Processed Values\n");
  23.     printf("===========\n");
  24.     i = 20+34;
  25.     f = 55.6*4.7;
  26.     ch = 'k'+3;
  27.     printf("i=%d\n", i);
  28.     printf("f=%f\n", f);
  29.     printf("ch=%c - %d\n", ch, ch);
  30.     //Input
  31.     printf("Please enter an integer: ");
  32.     scanf_s("%d", &i);
  33.     printf("Please enter a float: ");
  34.     scanf_s("%f", &f);
  35.     printf("Please enter a char: ");
  36.     scanf_s("%c", &ch, (unsigned int)sizeof(ch));
  37.     if (ch == '\n')
  38.     {
  39.         scanf_s("%c", &ch, (unsigned int)sizeof(ch));
  40.     }
  41.  
  42.     printf("i=%d\n", i);
  43.     printf("f=%f\n", f);
  44.     printf("ch=%c - %d\n", ch, ch);
  45.     //output
  46.     printf("Hello World");
  47.    
  48.    
  49.    
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement