Home Forums C Programming Welcome C++

Viewing 7 reply threads
  • Author
    Posts
    • #1948
      falguni1
      Participant

      Hi all
      My name is Vahid Majidi.
      I am learning C++, and I will be glad if I can answer questions of those newcommers to C++, to help others learn more and learn from others.
      Thanks

    • #3200
      bankkung
      Participant

      Hello my community,

      I am new to this forum & want to solve a project question.Ave tried my best but it is not executing, shows 8 errors. I am trying to find the prime numbers between 1 -7000.The sub intervals that holds themost  prime numbers and printing a histogram.

      #include<stdio.h>
      #include<conio.h>
      void main()
      {
       int num = 0;
       prime_num(num);
      }
       {
        for(int i=0;i<=7000;i++)
        {
        for(int j=2; j <= 7000;j++)
        {
         if( i != j && 1 != j)
         {
          return 0;
          break;
         }
         if(num%1 == num)
          {
          if (isprime)
          {
           printf("Prime:", i);
         }
          return 1;
        }
      • This reply was modified 7 years, 4 months ago by M. Saqib.
      • This reply was modified 2 years, 7 months ago by M. Saqib.
    • #3201
      annalith
      Participant

      hi my community give program.

      • This reply was modified 7 years, 4 months ago by M. Saqib.
      • This reply was modified 1 year, 7 months ago by M. Saqib.
    • #3202
      Jeevan M R
      Participant

      Hi Mr. Vahid Majidi, 
      I am Lalit Sharma and I have a query. 
      Please help me to write a program in C++, How to count all the three digit number tht lie between 100 to 300 and whose 1st & last digit is 2.
      If possible then please reply me at [email protected].
      Hope to hear from you

    • #3203
      [email protected]
      Participant

      How to count all the three digit number tht lie between 100 to 300 and whose 1st & last digit is 2?
      Ans:

      #include <iostream>
      using namespace std;
      void display()
      {
       int count = 0;
       for(int i = 100;i<300;i++)
       {
        int value = i;
        if(((value%10)== 2) &&(value/100)==2)
        {
         cout<<value<<endl;
         count++;
        }
       }
       cout<<"Total Number "<<count<<endl;
      }
      void main()
      {
       display();
      }
      
      output:
      202
      212
      222
      232
      242
      252
      262
      272
      282
      292
      Total Number 10
      • This reply was modified 7 years, 4 months ago by M. Saqib.
      • This reply was modified 2 years, 7 months ago by M. Saqib.
      • This reply was modified 2 years, 7 months ago by M. Saqib.
      • This reply was modified 2 years, 7 months ago by M. Saqib.
    • #3204
      S.Thananchayan
      Participant

      Thats awsome I was thinking about this one.
      This is the way I was going-
       

      #include <iostream>
      #include <algorithm>
      #include <vector>
      
      bool IsThis (int x) { return (x=1);  }
      bool IsAnswer (int i) { return (((i%10)==2)&(i/100)==2); }
      int main () {
        int mynumbers;
        int mycount;
      
        std::vector<int> myscope;
        for (int x =100; x<300; x++) myscope.push_back(x);
        std::vector<int> myvector;
        for (int i=100; i<300; i++) myvector.push_back(i);
       
        mynumbers = (int) count_if (myscope.begin(), myscope.end(), IsThis);
         std::cout << "myvector contains " << mynumbers  << " numbers between 100 and 300.n";
      
        mycount = (int) count_if (myvector.begin(), myvector.end(), IsAnswer);
         std::cout << "myvector contains " << mycount  << " numbers that begin and end with 2.n";
        return 0;
      }
      • This reply was modified 7 years, 4 months ago by M. Saqib.
      • This reply was modified 2 years, 7 months ago by M. Saqib.
      • This reply was modified 2 years, 7 months ago by M. Saqib.
    • #3205
      Jeevan M R
      Participant

      Hi Arun,
      I thank you very much for my problem solving.
      Dear Arun, I have not executed this program but I’ll try it today.
      Anyway many thanks once again.
       
      Thanks & Regards,
      Lalit Sharma
       
      “Knowledge speaks & Wisdom listens”.

    • #3206
      Jeevan M R
      Participant

      Hi mr_rich,
      I thank you very much for my problem solving.
      Dear friend, I have not executed this program but I’ll try it today.
      Anyway many thanks once again.
      Thanks & Regards,
      Lalit Sharma
       
      “Knowledge speaks & Wisdom listens”.

Viewing 7 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.