2021年7月14日 星期三

Exercise 4-4

 



#include <stdio.h>

 

int main() {

    int num;

    printf("enter a number: ");

    scanf("%d",&num);

    if (num%3==0)

        printf("It can be divided by 3.");

    else

        printf("It cannot be divided by 3.");

 

    return 0;

}

沒有留言:

張貼留言

如何於C程式內輸入字串?

之前我們學過如何於 C 程式內輸入數目字,但如要輸入字串,例如姓名,又要如何處理呢 ?   跟其他大部分電腦程言不一樣, C 並沒有一個字串的變數數據類型 (variable data type) , C 是使用字元 (character) 及變數陣列 (array)...