Advertisements
Advertisements
प्रश्न
Write a Python program to execute the following c++ coding.
#include<iostream>
using namespace std;
int main()
{ cout<<“WELCOME”;
return(0);
}
The above C++ program is saved in a file welcome. cpp.
थोडक्यात उत्तर
उत्तर
#include<iostream>
using namespace std;
int main( )
{
cout<<“WELCOME”;
retum(0);
}
Open Notepad and type python program and save as welcome.py
import sys,os,getopt
def main(argv):
cppfile =”
exefile = ”
opts, args = getopt.getopt(argv, “i:”, [ifile = ‘])
for o,a in opts:
if o in (“_i”,” ifile “):
cpp_file = a+ ‘.cpp’
exe_file = a+ ‘.exe’
run(cpp_file, exe_file)
def run(cpp_file, exe_file):
print(“compiling” +cpp_file)
os.system(‘g++’ +cpp_file + ‘_o’ + exe_file)
print(“Running” + exe_file)
print(“………………………….”)
print
os.system(exe_file)
print
if — name — == ‘–main –‘;
main(sys.argv[1:])
Output:
——————-
WELCOME
——————-
shaalaa.com
Python Program Executing C++ Program Using Control Statement
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?