Jumat, Juni 20, 2014

Define int Variable As Input On C Programming Language

Recognize at a glance about prophet Isya AS

Mother of Prophet Isya AS named Maryam. Maryam is single child of pair Imran and Hannah. When Hannah is being pregnant for some month, Imran was died, so Maryam was born as an orphan. Maryam had a vow to God, will hand over Maryam to Prophet Zakariya to manage house of Allah or Baitul Aqsa

Will be given example how to define integer variable int as input on C programming language, the way is:
  1. Open Dev C++
  2. File menu > New > Source File, then will be created a new worksheet titled Untitled1
  3. File menu > Save As. On Save as type: choose C source files (*.c) and on File name, example we give name define int integer variable as input.c
  4. First, type minimal required syntax on C programming:

    main()
    {
    }


  5. Add getch() function in main() function to show program result while be Run:

    main()
    {
      getch();
    }


  6. Define name of a integer variable signed int with syntax:

    signed int name_of_var_signed_int;

    so that program syntax becomes:

    main()
    {
      signed int name_of_var_signed_int;
      getch();
    }


  7. Use printf() function to define int variable as input with syntax:

    scanf("%d", &name_of_var_signed_int);

    so that program syntx becomes:

    main()
    {
      signed int name_of_var_signed_int;
      scanf("%d", &name_of_var_signed_int);
      getch();
    }


  8. Can be add sentence so that user of program knows when input a integer for signed_int variable

    main()
    {
      signed int name_of_var_signed_int;
      printf("Input an integer! ");
      scanf("%d", &name_of_var_signed_int);
      getch();
    }


  9. To show number inputted, use printf code %d

    main()
    {
      signed int name_of_var_signed_int;
      printf("Input an integer! ");
      scanf("%d", &name_of_var_signed_int);
      printf("%d", name_of_var_signed_int);
      getch();
    }


  10. Can be added sentence so that look more interesting

    main()
    {
      signed int name_of_var_signed_int;
      printf("Input an integer! ");
      scanf("%d", &name_of_var_signed_int);
      printf("Number is inputted: %d", name_of_var_signed_int);
      getch();
    }


  11. Can also added one or some signed int variable

    main()
    {
      signed int name_of_var_int1;
      signed int name_of_var_int2;
      printf("Input first integer! ");
      scanf("%d", &name_of_var_int1);
      printf("Input second integer! ");
      scanf("%d", &name_of_var_int2);
      printf("\nFirst integer is inputted: %d", name_of_var_int1);
      printf("\nSecond integer is inputted: %d", name_of_var_int2);
      getch();
    }




Source:

0 komentar: