Question

C language. I use nano text editor. Make a C program to do one of two...

C language. I use nano text editor. Make a C program to do one of two things: either print all of the parameters passed to it, or, if one of those parameters is "-h", print a few lines about what the program does. That is, if one of the parameters is "-h", it should not print the parameters, only the "help" message.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find my code:

#include <stdio.h>

int main(){

   // declaring an array of size 10 and initializing with 0
   int arr[10] = {0};

   int num = 0;

   printf("Enter integers in range 0-9 (-1 to stop)\n");
   scanf("%d", &num); // read first input
   while(num != -1){ // iterate if user input is not -1

       arr[num] = arr[num]+1; // increasing the count
       scanf("%d", &num); // read next input

   }

   // iterating arr and print count of each number
   int i;
   for(i=0; i<10; i++){
       printf("The number %d occured %d times\n",i, arr[i]);
   }


   return 0;
}

secondweek gcc printparams.c → secondweek ./a.out pravesh 5 Alex C -h hoili pravesh 5 Alex help hoili secondweek 1

Add a comment
Know the answer?
Add Answer to:
C language. I use nano text editor. Make a C program to do one of two...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Chet is trying to create a tail program for his windows machine so he can...

    Python Chet is trying to create a tail program for his windows machine so he can see the last N lines of a file or list of files. He wants the program to be usable by his friends and family so when an argument does not get passed to the program it should display a usage message. This is shown by the parser object by default but it's not doing it for him. The code works just not this one...

  • I need help with this question for programming. The language we use is C++ The program...

    I need help with this question for programming. The language we use is C++ The program should ask the user if they want to search for a boy or girl name. It should then ask for the name search the appropriate array for the name and display a message saying what ranking that name received, if any. The name files (BoyNames.txt and GirlNames.txt) are in order from most popular to least popular and each file contains two hundred names. The...

  • this assignment should be delivered in C language Program 4 will prompt the user for one...

    this assignment should be delivered in C language Program 4 will prompt the user for one or two token, space delimited, inputs of at most 20 characters. If the user provides more than 20 characters before a newline is reached print the provided error message. If the number of tokens is incorrect, print the appropriate error message. If the input is correct, print the appropriate token types. Prompt the user for input (and provide output) until the user provides a...

  • In the C language, Write a program that inputs 4 hexadecimal digits as strings (example 7F),...

    In the C language, Write a program that inputs 4 hexadecimal digits as strings (example 7F), converts the string digits to a long – use strtol(input string,&ptr,base) to do the conversion. Just declare ptr as a char ptr, don’t worry about what it does. Copy each converted number [ a long] into unsigned char’s [like the variable num1 below – hint: cast a long variable into the unsigned char’s] before performing the following logical operations on them (parenthesis might help,...

  • Using C programming language Question 1 a) through m) Exercise #1: Write a C program that...

    Using C programming language Question 1 a) through m) Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. a. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. b....

  • ‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels...

    ‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...

  • Using C language to write a program. First, to write Hello Wrold Second. Use a while...

    Using C language to write a program. First, to write Hello Wrold Second. Use a while loop to calculate the sum of positive even integers below 200 and print the result to the standard output. This is very similar to the sum example we have studied. Think about how much you should increase the loop control variable to get to the next even number. Your program should output the following text. output should be : Hello, World! 9900

  • Java program Program: Grade Stats In this program you will create a utility to calculate and...

    Java program Program: Grade Stats In this program you will create a utility to calculate and display various statistics about the grades of a class. In particular, you will read a CSV file (comma separated value) that stores the grades for a class, and then print out various statistics, either for the whole class, individual assignments, or individual students Things you will learn Robustly parsing simple text files Defining your own objects and using them in a program Handling multiple...

  • MASM Assembly language -- Message Encryption Pgm You are to write a program to input a...

    MASM Assembly language -- Message Encryption Pgm You are to write a program to input a text and a key and encrypt the text. I will supply you an encryption key consisting of multiple characters. Use this key to encrypt and decrypt the plain text by XOR-ing each character of the key against a corresponding byte in the message. Repeat the key as many times as necessary until all plain text bytes are translated. Suppose, for example, the key were...

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT