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.

Write a program that takes 4 numbers from the user and finds how many are odd

+1 vote
asked Mar 7, 2020 by grace

8 Answers

+1 vote
answered Mar 8, 2020 by anonymous
num = int(input(Enter num))

if num%2 != 0 :

      print("Odd no")
–1 vote
answered Mar 9, 2020 by FreeKill
#include <stdio.h>

int main()
{
    int odd=0,aux;
    for(int i=0;i<4;i++){
    printf("%d°",i);
    /*printf("%d%c",i,248);//Windows*/
    scanf("%d",&aux);
    if(aux%2)
    odd++;
    }
    printf("%d",odd);
    return 0;
}
–1 vote
answered Mar 11, 2020 by mahesh (120 points)

#include <stdio.h>

int main()
{
    int odd=0,aux;
    for(int i=0;i<4;i++){
    printf("%d°",i);
    /*printf("%d%c",i,248);//Windows*/
    scanf("%d",&aux);
    if(aux%2)
    odd++;
    }
    printf("%d",odd);
    return 0;
}

0 votes
answered Mar 12, 2020 by saichakrapani (160 points)
#include <stdio.h>
int main()
{
int i,n,odd,a[10];
odd=0;
printf("enter n value");
scanf("%d",&n);
for(int i=0;i<n;i++)
{
    scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i]%2!=0)
odd++;
}
printf("%d",odd);
    return 0;
}
+1 vote
answered Mar 12, 2020 by Vivek Manganure (160 points)
#include <iostream>

using namespace std;

int main()
{
    int a[4],odds = 0;
    cout<<"Enter numbers"<<endl;
    for(int i =0;i<4;i++)
    {
    std::cin >> a[i] ;
    if(a[i]%2 != 0)
    {
        odds++;
    }
    
    }
    cout<<"\n";
    cout<< "Odd numbers : " << odds ;
    return 0;
}
0 votes
answered Mar 12, 2020 by Arun Joseph (140 points)
a = [0,0,0,0]
evennum = 0
oddnum = 0
for i in range(4):
    a[i] = int(input("Enter number "+str(i+1)+": "))
    if a[i]%2 == 0:
        evennum = evennum + 1
    else:
        oddnum = oddnum + 1
print("No. of even numbers = "+ str(evennum))
print("No. of odd numbers = "+ str(oddnum))
0 votes
answered Mar 12, 2020 by Agent 007
//c program to find if the entered 4 numbers are odd or even

#include <stdio.h>

int main()
{
    int a[4],i;
    printf("Enter 4 numbers:");
    for(i=0;i<4;++i)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<4;++i)
    {
        if(a[i]%2==0)
        printf("%d is even\n",a[i]);
        else
        printf("%d is odd\n",a[i]);
    }

    return 0;
}
0 votes
answered Mar 14, 2020 by Sarmad Khan (180 points)
num = int(input("Enter num"))
if num%2 != 0 :
    print("Odd no")
else:
    print("Even no")
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.
...