siddhant3s 1,429 Practically a Posting Shark

Hi,
and here i am throwing a "not the exact version" of my problem, but if this is been solved, my problem is done.

Lets suppose i am building a application in c++ that will simply display the content of a text file.
I absolutely can make the app take the name of the file(to be opened) as a command line argument from the command prompt.
But What I want to do is: When a person double-clicks the text file(extention .txt) on windows explorer; My program should run showing the content of the file.
Tell me how to proceed;
I can very well right-click on the .txt files and choose "Open with" and select my program. But the problem is, how do I make my program respond to such actions.?
Pl Help;

siddhant3s 1,429 Practically a Posting Shark

There is a Buit in function called getpass in conio.h

Prototype : char *getpass(const char *prompt);

Displays the prompt string and then reads the password without echoing. Returns a pointer to a static string containing the input password.
Usage://include the conio.h and string.h

char a[20];

strcpy(a,getpass("Enter Pass"));
cout<<a;

siddhant3s 1,429 Practically a Posting Shark
siddhant3s 1,429 Practically a Posting Shark

Actually it is not function overloading. In Function overloading the return type and argument type is often different. It is more versatile and a different defination(i.e. different sets of instruction for same function) is been called.
Wherein in the default argument, only one defination is there. The default argument are optional.If they are not specified,the compiler specifies them by default.

Remember all the default argument should be placed from right. i.e. func(int x, int z=1, int y) is not allowed. int z=1 should be on the right.

siddhant3s 1,429 Practically a Posting Shark

want 200 digits or more ??

Here Dude, Your Problem Solved. I got your answer on www.ittb.co.nr while I was asking there experts to for an 200 digit calculator. So Here is the link to your problem. My advice is that you read completely.

http://ittb.pcriot.com/forum/viewtopic.php?t=23

siddhant3s 1,429 Practically a Posting Shark

ok.
Maybe your right.
Actually I too was frustated as dese ppl dont want to work. They just are trying to exploit the service.
I will remember this.
Thankx

siddhant3s 1,429 Practically a Posting Shark

TRY THIS OUT

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


int isPrime(unsigned long);
unsigned long power2( long);

void main()
{ clrscr();
for(int i=2;i<20;i++)
{
unsigned long val=power2(i) -1;

if (isPrime(val)==1)
{
cout<<i<<'\t'<<val<<'\n';

}

}


} //end main


int isPrime(unsigned long n)
{
for(unsigned long i=2;i<n/2;i++)
{
if(n%i==0)
return 0;
}
return 1;

}

unsigned long power2(long n)
{
unsigned long r=1;
for(int i=0;i<n;i++)
r*=2;

return r;

}

siddhant3s 1,429 Practically a Posting Shark

that didn't work plz help the assignment due today.

See, first of all we, in this community are there to help you not because you have paid us or we are servents or something.
You cant just say "it is not working". You need to specify what is the errors shown by the compiler or what is the undesired in the output.

Here on my machine i am having exactly the output you requested. But if you are not getting it, then you must tell us what is the problem.

Again I am giving you the program:

#include <iostream.h>
#include <math.h>

//using namespace std;

int isprime(unsigned long n)
{
   for(unsigned long i=2;i<n/2;i++)
   {
   if(n%i==0)
   return 0;
   }
   return 1;

}

int main()
{
    for(unsigned long i=2;i<1000;i++)
    {

    if (isprime(pow(2,i)-1))
    cout<<endl<<i<<'\t'<<pow(2,i)-1;

    }

    return 0;
} //end main
siddhant3s 1,429 Practically a Posting Shark

hi
can any one help with Mersenne Prime numbers calculator.
A prime number is defined as being a Mersenne Prime if it is of the form 2^n – 1,
where n is any integer greater than 1
display all the Mersenne primes from 2 through 1,000,000. Your results should be as presented below, under testing.


2 3
3 7
5 31
7 127
13 8191
17 131071
19 524287

please provide me with some examples

Here is the your solution :

#include <iostream.h>
#include <math.h>

//using namespace std;

int isprime(unsigned long n)
{
   for(unsigned long i=2;i<n/2;i++)
   {
   if(n%i==0)
   return 0;
   }
   return 1;

}

int main()
{
    for(unsigned long i=2;i<1000;i++)
    {

    if (isprime(pow(2,i)-1))
    cout<<endl<<i<<'\t'<<pow(2,i)-1;

    }

    return 0;
} //end main
siddhant3s 1,429 Practically a Posting Shark

I searched the forums but I didn't find any useful information. I am just trying to write a simple recursive solution to do F(n). It seems simple to me but I am probably not thinking about it correctly. My program has no errors, but it only returns 55 and then exits.

#include <iostream>

using namespace std;

int F(int);

int main()
{
    int fibonacci_input;
    cout << "Enter a positive integer to be Fibonacci'ed: ";
    cin >> fibonacci_input;
    cout << endl << F(fibonacci_input) << endl;
    return 0;
} //end main

int F(int n)
{
    if (n == 0)
        return 0;
    else if (n == 1)
        return 1;
    else
        return F(n-1)+F(n-2);
} //end F()

Okay Brother here is what your doing :
you input a value from the user and pass it as an argument to the function F(); right? now lets see what the function does if I pass 5.
Passing 10 executes the else statement i.e. return the sum of return value of F(4) and F(3) these in turn retruns the previous returns value. So in turn it returns :
0+1+1+2+3 and hence 5 is displayed.
But Actually you want to display all the values that are been encountered in the series.
Hence, you need to cout the F(0) then F(1) then F(2) then F(3) then F(4) .....till F(n)
Hence you will have to use the loop. Hence the revised code is :

#include <iostream.h>

//using namespace std;

int F(int);

int main()
{
    int …
siddhant3s 1,429 Practically a Posting Shark
switch(chii)
                            {
                                          'A' : strcpy(second1,"8F   ");      // Gives error here 
                                                strcpy(second2,"     ");
                                                break; 
                                                
                                          'B' : strcpy(second1,"88   ");    // Gives error here too!!
                                                strcpy(second2,"     ");
                                                break; 
                                                
                                          'C' : strcpy(second1,"89   "); // Gives error here too!!
                                                strcpy(second2,"     ");
                                                break; 
                                                
                                          'D' : strcpy(second1,"8A   ");  // Gives error here too!!
                                                strcpy(second2,"     ");
                                                break; 
                                                
                                          'E' : strcpy(second1,"8B   ");  // Gives error here too!!
                                                strcpy(second2,"     ");
												break; 
                                                
                                          'H' : strcpy(second1,"8C   ");  // Gives error here too!!
                                                strcpy(second2,"     ");
                                                break; 
                                                
                                          'L' : strcpy(second1,"8D   ");  // Gives error here too!!
                                                strcpy(second2,"     ");
                                                break;  
                            
                                        default: strcpy(second1,"8E   ");                     
                                                 
                            }
                            
                            
                            break;

You forgot to put a 'case' keyword in the inner switch. Your code shd be like :

switch(chii)
                            {
                                   case  'A' : strcpy(second1,"8F   ");      // Gives error here 
                                                strcpy(second2,"     ");
                                                break; 
                                                
                                      case 'B' : strcpy(second1,"88   ");    // Gives error here too!!
                                                strcpy(second2,"     ");
                                                break; 
                                                
                                         case 'C' : strcpy(second1,"89   "); // Gives error here too!!
                                                strcpy(second2,"     ");
                                                break; 

                                                .
                                                .
                                                .
                                                .
                                                .
                                                .
                                                .
                                                .
                                                .
siddhant3s 1,429 Practically a Posting Shark

I got the answer to your problem. It is one the website www.ittb.co.nr the actual link is : http://www.ittb.pcriot.com/forum/viewtopic.php?t=23

I hope you will be happy to see the solution.

siddhant3s 1,429 Practically a Posting Shark

Here is the improoved version

#include<iostream.h>
void main(){
int n;
do
{
cout<<"\Enter a Value bigger than 53: ";
cin>>n;
}while(n>53);

for(int i=7,j=0;i<n;i+=2,j++);
cout<<"\nThere are ";
cout<<j;
cout<<" odd number between 6 and";
cout<<n;
}

siddhant3s 1,429 Practically a Posting Shark

I got the answer to your problem. It is one the website www.ittb.co.nr the actual link is : http://www.ittb.pcriot.com/forum/viewtopic.php?t=23

I hope you will be happy to see the solution.

siddhant3s 1,429 Practically a Posting Shark

change the lines :

num =  a/num;
den=a;

to

num = num/a;
den= den/a;

I hope it helps