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
If a watermelon weighs 6 255 grams and a scales measures the weight 6 475 grams. What is the scales percent error
Liono4ka [1.6K]

Answer:scales percent error=3.51%

Step-by-step explanation:

P ercent error = Experimental value - Theoretical value /Theoretical value  x 100

Theoretical value = 6255 grams

Experimental value ( use of scale ) = 6475grams

Percent error =(6475- 6255)grams / 6255grams x 100

=220/6255 x 100

=3.51%

6 0
3 years ago
The quotient of 300 and the quality of x times 2
asambeis [7]
\frac{300}{ x^{2}} 
4 0
4 years ago
Read 2 more answers
&lt;5 and &lt;6 are complementary angles m&lt;5=13 what is the measure of &lt;6
Fiesta28 [93]
The measure of angle 6 can be found by subtracting the measure of angle 13 from 90.

90-13 = 77
6 0
3 years ago
3. A saving's account began with a balance of $250. The relationship between the number of
ch4aika [34]
The rate of change of the balance was $175 per deposit which is C
7 0
3 years ago
PLEASE ANSWER ASAP WITH WORK FOR BRAINLEST!!!!!!!!!!!!!!!!
-BARSIC- [3]
First divide both sides by 12 so u get 5x -4.5 = 3. Now add 4.5 to both sides and u get 5x = 7.5. Now divide 7.5 by 5 and u get 1.5
6 0
3 years ago
Other questions:
  • Three gallons of paint are used to paint 16 wooden signs.how much paint did each sign use. Between what two whole numbers does t
    9·1 answer
  • Sonja went hiking for 4 hours. For how many minutes did she go hike
    10·2 answers
  • Question
    11·1 answer
  • Last year there were 120 students in choir. This year, 30% more students took choir. How many students are taking choir this yea
    8·1 answer
  • Which of the following are identities? Check all that apply. A. sin^2x - cos^2x = 1 B. sin^2x = 1 - cos^2x C. tan^2x = 1 + sec^2
    6·2 answers
  • Question 3 please help me For final exam
    15·2 answers
  • Winnie needs to spend $120 on two kinds of fancy cakes:
    15·1 answer
  • Hello please help me solve this :) will give braisnlt xo
    13·2 answers
  • What is the number? I did many ways but i didn't found it, please guys help me with it. ​
    6·1 answer
  • Give work for equations following:<br><br> -x+2y&lt;-4<br> 2x+3y&gt;6<br><br> thanks sooooo much!!!!
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!