Computer Science, asked by kanugulanavya1527, 3 months ago

//There are 2 numbers x and y in file 1.txt . Read these 2 numbers from file and store swapped values of x and y in file2.txt.
//write a program to complete the program in c language

Answers

Answered by nkcthereaper
0

Answer:

with open("1.txt","r") as r:

   

   rr=r.read()

   rr=rr.split()

   x=[]

   print(rr)

   for i in rr:

       if i.isdigit() is True:

           x.append(eval(i))

   print(x)

   first=x[0]

   second=x[1]

   print('first no=',first)

   print('second no=',second)

   first,second=second,first

with open("2.txt","w") as r:

   r.write(str(first)+"\n")

   r.write(str(second))

Explanation:

Answered by DevilHunter001
0

Answer:

Answer:

with open("1.txt","r") as r:

   

   rr=r.read()

   rr=rr.split()

   x=[]

   print(rr)

   for i in rr:

       if i.isdigit() is True:

           x.append(eval(i))

   print(x)

   first=x[0]

   second=x[1]

   print('first no=',first)

   print('second no=',second)

   first,second=second,first

with open("2.txt","w") as r:

   r.write(str(first)+"\n")

   r.write(str(second))

Explanation:

Similar questions