Skip to content

MyUstaadG

Learn to Serve

  • Computer Science
    • Software
    • Computer Tips
    • Coding
      • Conditional Structures Exercises
      • Loops Exercises
      • Arrays Exercises
      • Python Exercises
    • Microsoft Office
      • MS Excel
      • MS Word
  • Videos
    • Funny Videos
    • Health and Fitness Videos
    • PUBG Videos
    • Technology Videos
  • News
  • Funny
  • Memes
  • Playwright Tutorials
  • Tutorials
  • Toggle search form

Write a program to input an array of 10 elements from the user and count the number of odd numbers and display it.

Posted on October 16, 2021 By myustaadg.com
Spread the love

Write a program to input an array of 10 elements from user and count the number of odd numbers and display it.

So let’s Write Code:

Introduction to C++ Programming | Download and Install Dev C++ Compiler

Let’s build logic First:

Algorithm for code:

  • Step 1: Start
  • Step 2: Declare an array and varaiable odd.
  • Step 3: Initialaize odd = 0;
  • Step 4: Take inputs from user.
  • Step 5: Check condition if(arr[i]% == 1) add value in odd,
  • Step 6: Print odd
  • Step 7: End Progarm

Code:

Write a program to input an array of 10 elements from the user and count the number of odd numbers and display it.

#include<iostream>
using namespace std;
main()
{
int ar[10], odd = 0;
for(int i=0; i<=9; i++) 
{
cout<<"Enter value in element "<<i<<" ? ";
cin>>ar[i];
if (ar[i]%2 == 1)
odd = odd + 1;
}
cout<<"Number of odd values in array are : "<<odd<<endl;
}

Hope You will learn Something. Happy Coding.

Visit my YouTube Channel as Well๐Ÿ˜‡ https://www.youtube.com/watch?v=JuIHQ9cLSEw&list=PLbIhkHxfUIItTdcyCb34uRIrPJbXBndIl&index=4

Click on the below Links for more Programming Exercises:

Conditional Structure Exercises: ๐Ÿ‘‰https://myustaadg.com/category/programming-exercises/conditional-structures-exercises/

Array Exercises: ๐Ÿ‘‰https://myustaadg.com/category/programming-exercises/arrays-exercises/

Arrays Exercises, Programming Exercises Tags:Array Exercises, Array exercises in C++, array in Object oriented programming, array in OOP, Arrays in C++, c program to count odd numbers using for loop, c++ program to check if a given number is even and odd, c++ program to check nu ber is even and odd, c++ program to check whether number is even or odd, c++ program to count number of odd elements in array, c++ program to print odd numbers in an array, count odd numbers of an array in c++, how do you count an odd number in an array, how do you count how many odd numbers in an array, how do you count odd numbers in c++, how do you represent an odd number in c++, how to find and display odd number, hw do you count odd number in c, program to count odd numbers, write a c++ program to count odd numbers from given 10 numbers, Write a program to input an array of 10 elements from the user and count the number of odd numbers and display it.

Post navigation

Previous Post: Write a program that inputs 10 numbers into an array and finds out the second largest value from that array.
Next Post: Write a program that inputs values into an array and finds the smallest and largest value from it.

More Related Articles

Write a program that inputs integer values in an array of 10 elements in main() function and passes the array to a function. The function counts odd integer values. Arrays Exercises
Write a program that stores the string in a variable, asks the user for the password, and prints on the screen base on condition | Python Programming Programming Exercises
Write a program that initializes values 2, 6, 3, 5, 4 and 7 in one-dimensional array and computes the factorial. Arrays Exercises
Write a program that inputs marks of ten students in an array and counts the number of students that have marks between 80 and 100. Arrays Exercises
Write a program that inputs values into int type array. It reads the value from array and draws a bar chart by printing asterisks. Arrays Exercises
Write a program that inputs ages of different persons in an array and counts the number of persons that have ages between 65 and 80. Arrays Exercises

Copyright © 2022 MyUstaadG.

Powered by PressBook Blog WordPress theme