Computer Science, asked by diya72, 1 year ago

guys I have doubt in these que....I will give many points​

Attachments:

Answers

Answered by magsparikh
1

it isn't possible to write all 15 java programs.....

sorry


yashthoapte11: plz tell
Shreya69614: can u guys use ur inbox?
yashthoapte11: how to use inbox
Shreya69614: it's in the upper right corner
Shreya69614: a 'message' looking icon
Shreya69614: tap on that and add each other
Shreya69614: and talk privately
yashthoapte11: ok
yashthoapte11: diya accept my request
yashthoapte11: diya are online
Answered by Shreya69614
3

2. for even numbers - will be done the same way as mentioned below except the number in output should come out to be even.

3. (for odd number)

#include <iostream>

using namespace std;

int main(){

   for(int i = 0; i < 10; i++){

       cout << 2 * i + 1 << ' ';

   }

   return 0;

}

5. sum of first 10 number

#include <iostream>

using namespace std;

int main()

{

   int i,sum=0;

   cout << "\n\n Find the first 10 natural numbers:\n";

   cout << "---------------------------------------\n";

   cout << " The natural numbers are: \n";

   for (i = 1; i <= 10; i++)

   {

       cout << i << " ";

 sum=sum+i;

   }

    cout << "\n The sum of first 10 natural numbers: "<<sum << endl;

}


Shreya69614: we did that to get odd number
Shreya69614: odd number is of the form 2q+1
Shreya69614: and q will start from 1 for first n natural numbers
yashthoapte11: shreeya you can do java too
Shreya69614: i've studied java, so i can try answering some questions
yashthoapte11: plz add me as friend so if have doubt I will ask
Shreya69614: ask ur question, I'll try
Shreya69614: try to answer *
yashthoapte11: no I don't have now but later
Shreya69614: ok
Similar questions