Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

To print even or odd number

0 votes
asked Nov 3, 2018 by anonymous

4 Answers

0 votes
answered Nov 3, 2018 by Nani Sri harsha reddy
Nani Sri harsha reddy
0 votes
answered Nov 4, 2018 by faaa
#include<stdio.h>

#include<conio.h>

int main(){

int bil;

printf("Masukkan Bilangan : ");

scanf("%d", &bil);

if (bil % 2)

{

printf("Bilangan %d merupakan bilangan ganjil", bil);

puts("\nKarena tidak bisa dibagi 2");

}

else

{

printf("Bilangan %d merupakan bilangan genap", bil);

puts("\nKarena bisa dibagi 2");

}

getch();

}
0 votes
answered Nov 5, 2018 by anonymous
if(num%2==0)

printf("number is even");

else

printf("number is odd");
0 votes
answered Nov 5, 2018 by anonymous
#include <stdio.h>

int main()
{
    int num; // Declare integer vairable 'num' to hold entered number
    
    printf("Enter number: "); // Display message to enter number
    
    scanf("%d", &num); // Read number in 'num' variable
    
    /* If remainder of number divide by 2 is 0 then number is even,
     * otherwise number is odd
     */
    if(num%2==0) {
        printf("Number is even\n");
    } else {
        printf("Number is odd\n");
    }
    
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...