1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aalyn [17]
3 years ago
9

a. For a file whose size (in terms of number of bytes) is less than or equal to 12, then duplicate the contents of the file so t

hat its total size would be twice as many as its original size.
Mathematics
1 answer:
pickupchik [31]3 years ago
4 0

Answer:

#include <stdio.h>

int main()

{

int check;

char* dirname = "Subdir1";

check = mkdir(dirname,0766);

// check if directory is created or not

if (!check)

{

printf("Subdir1 Directory created\n");

 

char *dirname1="/Subdir1/D1";

if(mkdir("/Subdir1/D1", 0777)==-1)

{

printf("D1 Directory created\n");

int A1 = open ("/Subdir1/D1/A1.txt", 0666);

write(A1, "abcdefghij\n", strlen("abcdefghij\n"));

close(A1);

 

int A2 = open ("/Subdir1/D1/A2.txt", 0666);

write(A2, "you are beautiful\n", strlen("you are beautiful\n"));

close(A2);

 

int A3 = open ("/Subdir1/D1/A3.txt", 0666);

write(A3, "this is terrible!\n", strlen("this is terrible!\n"));

close(A3);

}

else

{

printf("Unable to create directory D1\n");

exit(1);

}

if(mkdir("/Subdir1/D2", 0777)==-1)

{

printf("D2 Directory created\n");

int B1 = open ("/Subdir1/D2/B1.ccc", 0664);

write(B1, "abcdefghij\n", strlen("abcdefghij\n"));

close(B1);

 

int B2 = open ("/Subdir1/D2/B2.ccc", 0664);

write(B2, "you are beautiful\n", strlen("you are beautiful\n"));

close(B2);

 

int B3 = open ("/Subdir1/D2/B3.ccc", 0664);

write(B3, "this is terrible!\n", strlen("this is terrible!\n"));

close(B3);

}

else

{

printf("Unable to create directory D2\n");

exit(1);

}

 

if(mkdir("/Subdir1/D3", 0777)==-1)

{

printf("D3 Directory created\n");

int C1 = open ("/Subdir1/D3/C1.txt", 0644);

write(C1, "abcdefghij\n", strlen("abcdefghij\n"));

close(C1);

 

int C2 = open ("/Subdir1/D3/C2.ddd", 0644);

write(C2, "you are beautiful\n", strlen("you are beautiful\n"));

close(C2);

 

int C3 = open ("/Subdir1/D3/C3.txt", 0644);

write(C3, "this is terrible!\n", strlen("this is terrible!\n"));

close(C3);

}

else

{

printf("Unable to create directory D2\n");

exit(1);

}

 

}

 

 

else {

printf("Unable to create directory Subdir1\n");

exit(1);

}

return 0;

}

Program 2:

#include <stdio.h>

 

long int findSize(char file_name[])

{

// opening the file in read mode

FILE* fp = fopen(file_name, "r");

 

// checking if the file exist or not

if (fp == NULL) {

printf("File Not Found!\n");

return -1;

}

 

fseek(fp, 0L, SEEK_END);

 

// calculating the size of the file

long int res = ftell(fp);

 

// closing the file

fclose(fp);

 

return res;

}

 

// Driver code

int main()

{

FILE *fptr1;

char c;

char file_name[] = {"D1.txt"};

long int res = findSize(file_name);

if (res != -1)

{

printf("Size of the file is %ld bytes \n", res);

if(res<=12)

{

fptr1 = fopen("D1.txt", "r");

c = fgetc(fptr1);

while (c != EOF)

{

fputc(c, fptr1);

c = fgetc(fptr1);

printf(c);

}

}

}

return 0;

}

You might be interested in
24 is 0.6% of what number
algol [13]
Hello! The answer would be,
38.4
Since if you do 24x0.6 you would get 14.4 which then you would add
14.4 with 24 and get 38.4
Hope I've helped and feel free to ask me questions!

Sincerely, Kaylie :)
8 0
3 years ago
Read 2 more answers
Tito Jackson had $30.85. He took a girl on date to a nice restaurant, and the bill was $48. 67. How much money does he have in h
meriva

Answer:

$-17.82

Step-by-step explanation:

he has $-17.82 because 30.85(the amount he has)-48.67(the amount he paid for) = -17.82

6 0
2 years ago
Read 2 more answers
INSTRUCTIONS<br> Solve the division problems<br> Name
skad [1K]

Answer:

13

Step-by-step explanation:

Do the divison! :D It's hard to write out on here, but you can find a lot of other online resources on how to do it, I reccomend Khan Academy.

5 0
3 years ago
PLEASE HELP MEEE!! ASAP! I will mark brainliest
Free_Kalibri [48]

Answer:

The last 1 (D)

Step-by-step explanation:

The lines have to be straight nd have to pass through the origin

7 0
2 years ago
Read 2 more answers
Kaitlyn can run 1.35 miles in 12 minutes. What is her running speed per hour?
vazorg [7]

Answer:

the answer is 6.75

Step-by-step explanation:

12 x 5 = 60 60 = 1 hour so 1.35 x 5 = 6.75

7 0
2 years ago
Other questions:
  • Convert: 9 cubic meters to cubic feet (to the nearest tenth).
    8·2 answers
  • The ratio of the prices of Emma's phone to Sophie's phone is 7:8. If Sophie's phone costs $640, how much should the prices of th
    7·2 answers
  • Of the sundaes recently sold at Ice Cream Haven, 9 had nuts and 6 did not. Considering this data, how many of the next 10 sundae
    5·1 answer
  • Need help with please
    11·1 answer
  • what it the better value for the money, $8.99 for a package of 8 cold remedy capsules or $2.25 for 2 capsules​
    8·1 answer
  • 2 3/4 - 3/7<br><br> 10 points
    8·2 answers
  • Click an item in the list or group of pictures at the bottom of the problem and, holding the button down, drag it into the corre
    8·1 answer
  • Due in 6 hours please help.
    6·2 answers
  • I need help with this
    15·1 answer
  • Sixth grade &gt; H.5 Divide decimals by whole numbers: word problems TWZ
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!