This C programming example is to check whether a given number is divisible by 3 or not. You can achieve this by applying multiple programming logic. Here, modulus operator (%) is used to find out if entered number is divisible by 3.
#include <stdio.h> int main() { int number; printf("Enter number:\n"); scanf("%d",&number); if ((number % 3) == 0) printf("%d is a multiple of 3",number); else printf("%d is not a multiple of 3",number); return 0; }
Case 1: Enter number: 493648 493648 is not a multiple of 3 Case 2: Enter number: 98274651 98274651 is a multiple of 3
1. This program simply asks user to input an integer number. 2. In order to check for its divisibility by 3, modulus operator (%) is used. This operator return the remainder after dividing the given number by another number. 3. If the modulus operator return 0 as remainder, the number is multiple of 3. Otherwise, it is not a multiple of 3.
Questions from Previous year GATE question papers
UGC NET Previous year questions and practice sets
Attempt a small test to analyze your preparation level. This GATE exam includes questions from previous year GATE papers.
Practice test for UGC NET Computer Science Paper. The questions asked in this NET practice paper are from various previous year papers.