Home › Forums › C Programming › Welcome C++
- This topic has 7 replies, 6 voices, and was last updated 17 years, 4 months ago by Jeevan M R.
- AuthorPosts
- September 19, 2006 at 1:34 am #1948falguni1Participant
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 - October 3, 2006 at 10:18 am #3200bankkungParticipant
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.
C12345678910111213141516171819202122232425#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;} - March 28, 2007 at 7:07 am #3201
- July 25, 2007 at 4:35 am #3202Jeevan M RParticipant
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 - July 31, 2007 at 5:11 am #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:C123456789101112131415161718192021222324252627282930313233#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:202212222232242252262272282292Total Number 10 - July 31, 2007 at 10:33 am #3204S.ThananchayanParticipant
Thats awsome I was thinking about this one.
This is the way I was going-
C12345678910111213141516171819202122#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;} - August 1, 2007 at 1:34 am #3205Jeevan M RParticipant
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”. - August 1, 2007 at 1:35 am #3206Jeevan M RParticipant
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”.
- AuthorPosts
- The forum ‘C Programming’ is closed to new topics and replies.