0% found this document useful (0 votes)
5 views

10

The document contains multiple C++ code snippets that demonstrate basic programming concepts such as inputting numbers, calculating sums, and generating random numbers. It includes functionality to count positive, negative, even, and odd numbers from a generated list. Additionally, there are some incomplete or erroneous sections and comments throughout the document.

Uploaded by

paid games
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

10

The document contains multiple C++ code snippets that demonstrate basic programming concepts such as inputting numbers, calculating sums, and generating random numbers. It includes functionality to count positive, negative, even, and odd numbers from a generated list. Additionally, there are some incomplete or erroneous sections and comments throughout the document.

Uploaded by

paid games
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#include <iostream>
using namespace std;
int main()
{
int numbers[5], sum = 0;
cout << "Enter 5 numbers";

//Storing 5 number entered by user in an arry


//Finding the sum of numbers entered
for (int i = 0; i < 5; ++i)
{
cin >> numbers[i];
sum += numbers[i];
}

cout << "Sum = " << sum << endl;

return 0;

}
2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
hold
3\\\\\\\\\on my
own \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
with errors
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <conio.h>

using namespace std;


int main()
{
int values [20], i, pos = 0, neg = 0, even = 0, odd = 0;
cout << "Random no, Generator " << endl;
for (i = 0; i < 20; i++)
{
values[i] = (1 + (rand() % 10)) - 5;
}
for (i = 0; i < 20; i++) {

if ((i % 10) == 0)
cout << endl;
cout << values[i] << "";
}
for (i = 0; i < 20; i++) {
(values[i] < 0) ? neg++ : pos++;
((values[i] % 2 == 0)) ? even++ : odd++;
}
cout << endl << "EVEN = " << even << "ODD = " << odd << endl;
cout << "POS = " << pos << "NEG = " << neg << endl;
getch();
}
only neg bhi hai also +
3\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
caht \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <conio.h>

using namespace std;


int main()
{
int values [20], i, pos = 0, neg = 0, even = 0, odd = 0;
cout << "Random no, Generator " << endl;
for (i = 0; i < 20; i++)
{
values[i] = (1 + (rand() % 10)) - 5;
}
for (i = 0; i < 20; i++) {

if ((i % 10) == 0)
cout << endl;
cout << values[i] << "";
}
for (i = 0; i < 20; i++) {
(values[i] < 0) ? neg++ : pos++;
((values[i] % 2 == 0)) ? even++ : odd++;
}
cout << endl;

}
4//////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////

histogram

You might also like