Single File Programming QuestionProblem StatementBalaji is interested in creating a program to display a list of fruits and vegetables. Write a simple C program for him that uses the printf function to display the following table contents:Ensure the program accurately displays the fruits and vegetables in two rows separated by a tab space.Input format :No console input.Output format :The output displays the fruits in the first line and vegetables in the second line as shown in the table in the problem statement, separated by a tab space.Refer to the sample output for formatting specifications.Sample test cases :Input 1 :Output 1 :Apple Banana Guava Orange StrawberryCarrot Beans Beetroot Chilly OnionNote :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Question
Single File Programming QuestionProblem StatementBalaji is interested in creating a program to display a list of fruits and vegetables. Write a simple C program for him that uses the printf function to display the following table contents:Ensure the program accurately displays the fruits and vegetables in two rows separated by a tab space.Input format :No console input.Output format :The output displays the fruits in the first line and vegetables in the second line as shown in the table in the problem statement, separated by a tab space.Refer to the sample output for formatting specifications.Sample test cases :Input 1 :Output 1 :Apple Banana Guava Orange StrawberryCarrot Beans Beetroot Chilly OnionNote :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Solution
Here is a simple C program that will display the list of fruits and vegetables as per your requirement:
#include <stdio.h>
int main() {
printf("Apple\tBanana\tGuava\tOrange\tStrawberry\n");
printf("Carrot\tBeans\tBeetroot\tChilly\tOnion\n");
return 0;
}
This program uses the printf function to display the fruits and vegetables. The \t inside the printf function is used to create a tab space between the items, and the \n is used to create a new line. The first printf function call prints the fruits, and the second one prints the vegetables.
Similar Questions
Balaji is interested in creating a program to display a list of fruits and vegetables. Write a simple C program for him that uses the printf function to display the following table contents:Ensure the program accurately displays the fruits and vegetables in two rows separated by a tab space.Input format :No console input.Output format :The output displays the fruits in the first line and vegetables in the second line as shown in the table in the problem statement, separated by a tab space.Refer to the sample output for formatting specifications.Sample test cases :Input 1 :Output 1 :Apple Banana Guava Orange StrawberryCarrot Beans Beetroot Chilly OnionNote :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Single File Programming QuestionProblem StatementHarbhajan is learning about formatting output in C. Create a simple program for him that declares two integer variables, m with a value of 8, and n with a value of 10. Use the printf function to display these integers in a single line, separated by two tab spaces.Input format :No console input.Output format :The output displays the values of m and n, separated by two tab spaces.Refer to the sample output for formatting specifications.Sample test cases :Input 1 :Output 1 :8 10Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
ingle File Programming QuestionProblem StatementTwo friends met after a long time and had a casual conversation. Create a C program to simulate this conversation using multiple printf statements by correctly using new lines and required spacing.The conversation is as follows:Hi Adam, how are you?Hi Eve, I am fine. How are you?I am fine. How's life going on?Input format :No console input.Output format :The output displays the conversation using proper spacings and new lines as shown in the problem statement.Refer to the sample output for formatting specifications.Sample test cases :Input 1 :Output 1 :Hi Adam, how are you?Hi Eve, I am fine. How are you?I am fine. How's life going on?Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.Marks : 10Negati
Single File Programming QuestionProblem StatementA farmer wants to assess the average yields of two different crops from their last two harvests. Design a program that takes the yield (in kilograms) for each crop from the two harvests as input.Calculate the average yield of each crop and also determine print which crop had the highest average yield using the conditional (ternary) operator.Input format :The first line consists of two space-separated double values m1 and n1, representing the yields for Crop 1 (in kilograms) for Harvest 1 and Harvest 2, respectively.The second line consists of two space-separated double values m2 and n2, representing the yields for Crop 2 (in kilograms) for Harvest 1 and Harvest 2, respectively.Output format :The first line prints "Crop 1: X kg" where X is a double value representing the average yield of Crop 1 in both harvests rounded to two decimal places.The second line prints "Crop 2: Y kg" where X is a double value representing the average yield of Crop 2 in both harvests rounded to two decimal places.The third line prints "Crop Z had the highest average yield" where Z is the crop number that had the highest yield.Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, test cases fall under the following constraints:100.0 ≤ m1, n1, m2, n2 ≤ 1000.0Sample test cases :Input 1 :152.2 125.1100.0 123.0Output 1 :Crop 1: 138.65 kgCrop 2: 111.50 kgCrop 1 had the highest average yieldInput 2 :456.2 567.4965.0 1000.0Output 2 :Crop 1: 511.80 kgCrop 2: 982.50 kgCrop 2 had the highest average yieldNote :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Single File Programming QuestionProblem StatementJenifer is developing a program for a warehouse management system that needs to analyze inventory data. The program receives an array representing the quantities of different products in the warehouse. The task is to count the number of items falling within a specified range of quantities. Help Jenifer to accomplish her task using pointers.Input format :The first line of input consists of an integer N, representing the number of products in the warehouse.The second line consists of N space-separated integers, representing the quantity of products.The third line consists of two space-separated integers, representing the lower limit and upper limit (range).Output format :The output prints the number of products falling within the specified range (both inclusive) of quantities.Refer to the sample output for formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ N ≤ 251 ≤ quantity ≤ 100Sample test cases :Input 1 :1015 25 35 45 55 65 75 85 95 10045 85Output 1 :5Input 2 :523 29 34 48 5935 60Output 2 :2
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.