QuestionQuestion

1. Loop Pyramids: The problem is divided into the following two parts.
(a) For this problem you will print a pyramid with r rows. Your program should read the value of r
from the standard input. The pyramid will be printed to standard output. For instance if the user chooses r = 4, the expected output is the following.
<newline> represents the new line character.
Assume the following will hold: 1 ≤ r < 80. Please name this C file “Problem1 a.c”
(b) This problem is almost identical to part a. Your program should read the number of rows r from the standard input and should print a reverse pyramid in the standard output. The only difference from part (a) is the pyramid shape.
For instance if the user were to choos r=4, the expected output is the following. <space> and
<newline> represent the space and the new line characters, respectively.
Assume the following will hold: 1 ≤ r < 80. Please name this C file “Problem1 b.c”

2. Palindrome: A palindrome, in our context, is a word that reads the same even when it is read backwards. For instance, radar, mom, noon, and kayak are all palindromes whereas homework, assignment, and operating are not. For this problem, you can safely assume that words will not contain the newline or space characters but can contain other printable ASCII characters.
The maximum length of a word will be 1024. You will read your inputs from the standard input and print all your outputs in the standard output.
The first line of your program’s input is N (i.e., 1    N    100) which indicates the number of words    for which you would need to decide whether that word is a palindrome. Then N lines will follow where each of the N lines will contain a word you need to test. If your word is a palindrome you should print “PALINDROME <newline>” (without the quotes) whereas print “NOT<space>PALINDROME<newline>” (without the quotes) when the word is not palindrome.
Please name this C file“Problem2.c”

3. File Size: Write a C program that will take a file name f as a command line argument and will display in the standard output the size of f in bytes . You can safely assume that file names are C-type strings (with a null character at the end) of maximum length 32.
For this problem, you can neither use the ftell nor the fseek functions. Please name this C file“Problem3.c”

4. Max/Min/Avg/Med: Write a C program that calculates the maximum (Max), minimum (Min), average (Avg), and median (Med) values of a sequence of integers. For this problem, you will take input from the standard input and display your program’s results in the standard output.
The first line of the input is an integer T indicating the number of test cases your program should handle. T test cases follow. Each of the T test cases starts with the value N indicating the number of integers in the sequence. N integers would follow. Your program should print the following information (in the order of their appearance): the maximum value among the N integers, the minimum value among the N integers, the average of the N integers, and the median of these N integers.
Max, Min and Median should be of the int type while the average should be of the float type.
Sample input: <newline> represents the new line character.
Expected output for the sample input:
When printing out the average value, please do NOT round up. Simply print out the value in the default format.
Please name this C file“Problem4.c”

5. Printing Integers in the Ascending Order: Write a C program that prints a list of input integers in the ascending order. Your program should take input from the standard input and the output should be displayed in the standard output.
The first line of the input is T representing the number of test cases your program should handle. T test cases will follow. Each of the T test cases will start with a line containing the integer N indicating the number of integers in the list. Then N integers would follow; one in each line. Your program should print these N integers in the ascending order for each test case.
Sample input:
Expected output of the sample input:
Please name this C file“Problem5.c”

6. Fibonacci Number: Write a C program that recursively calculates the N th Fibonacci number. Your program should take input from the standard input and display its output in the standard output.
The precise input format is as follows. The first line of the input will contain the integer T indicating the number of test cases your program needs to handle. T test cases will follow. For each of the T test cases, the value of N will be given. Your program should print the N th Fibonacci number. You can assume the value of N to be small enough so that the N th Fibonacci number will fit into a unsigned long long int (8 bytes).
Sample input:
Expected output for the sample input:
Please name this C file“Problem6.c”

7. GCD: Write a C program to recursively calculate the Greatest Common Divisor (GCD) of two positive integers. The GCD is the largest positive integer that is able to divide each of the   given integers. For instance, the GCD of 8 and 12 is 4.
Your program should take input from the standard input and print the output in the standard output. The precise format of the input is given below. The first line of the input is an integer T indicating the number of test cases your program should handle. T test cases will follow. For each of the T test cases, the input will contain two space-separated positive integer n1 and n2 such that n1 and n2 will both fit into a 32-bit integer (i.e., int). The output for a particular n1 and n2 is their GCD followed by   a newline.
Sample input:
Expected output of the sample input:
Please name this C file “Problem7.c”

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv) {
   
    int r;
    int i;
    int j;
    scanf("%d", &r);
   
    for (i = 1; i <= r; i++) {      
       for (j = 1; j <= i; j++) {
            printf("*");
       }
       printf("\n");
    }
   
    return (EXIT_SUCCESS);
}


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv) {
   
    int r;
    int i;
    int j;
    scanf("%d", &r);
      
    for (i = 1; i <= r; i++) {
       for (j = 0; j < r - i; j++) {
            printf(" ");
       }
       for (j = 1; j <= i; j++) {
            printf("*");
       }
       printf("\n");
    }
   
    return (EXIT_SUCCESS);
}...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

50% discount

Hours
Minutes
Seconds
$65.00 $32.50
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats