मराठी
तामिळनाडू बोर्ड ऑफ सेकेंडरी एज्युकेशनएचएससी विज्ञान इयत्ता १२

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. - Computer Science

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 14: Importing C++ programs in Python - Evaluation [पृष्ठ २९०]

APPEARS IN

सामाचीर कलवी Computer Science [English] Class 12 TN Board
पाठ 14 Importing C++ programs in Python
Evaluation | Q 5. | पृष्ठ २९०
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×