-1

I need to write a c program which takes a algorithm as the input and gives the equivalent c source code as the output.any ideas????

9
Contributors
10
Replies
21
Views
7 Years
Discussion Span
Last Post by Anuradha Mandal
Featured Replies
  • 1
    WaltP 2,905   7 Years Ago

    Of course you need help. Isn't that obvious? But [I]you[/I] need to give a very specific set of guidelines about [I]exactly[/I] what you need. What "algorithms"? Based on your almost description above, check each character input and create variables for [iCODE]num1[/iCODE], [iCODE]num2[/iCODE], and [iCODE]operation[/iCODE]. Then test the operation and perform … Read More

-1

The easiest way to do this is to write a program that takes a problem as the input and gives the source code of the solution... then you can use it to solve this problem.

Seriously though, what kind of algorithm? Don't say "any"!

0

difficult!

Algorithms are just general guides, they have to adjusted for every specific problem. There are programs that do this, for a very limited environment, and limited algorithms, but they are a very big project.

Not something for the beginner.

-2

Actually its enuf if ican write a program which can convert simple c algorithms to c source code like sum of two numbers
i need some help

1

Of course you need help. Isn't that obvious?

But you need to give a very specific set of guidelines about exactly what you need. What "algorithms"?

Based on your almost description above, check each character input and create variables for num1 , num2 , and operation . Then test the operation and perform it on the two numbers.

-1

sample input
1-get input in a and b
2-add a and b
3-display the result
4-stop

now this program should give a c program as output which takes 2 numbers as input and returns the sum as output

0

You want a very high level programming domain-specific programming language. Treat the problem as such and you'll be less confused as how to proceed. However, creating a language (even a simple one) can be a surprisingly difficult undertaking if you're new to that particular field. I'd suggest making your "algorithm" language look more like assembly language for simpler parsing, then work your way up to a more prose/list-like grammar.

0

Also i want to say that this question is related to compiler design. So i would suggest to learn compiler design/programming in general, before advancing to concrete problem.

-2

1) First you have to take 2 variables like int a,b,s;
2) Then add a and b.
3) Then print the output.

int a,b,s;
cout<<"Enter value for a : ";
cin>>a;
cout<<"Enter value for b : ";
cin>>b;
//now add them
s=a+b;
//Now print s
cout<<s;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.