command-line argument


1. Please briefly describe what the run time error is in C language.
2. Write a program that prints each command-line argument on a new line.
Example:
Input in CMD: ./program hello world
Output:
3. Write a program that reads a line of text from the user using fgets and prints it 
back.
Example:
Input from the keyboard:
Output to the screen:
4. Write a program that reads a line of text using fgets and calculates its length 
(excluding the newline character).
Example:
Input from the keyboard:
Output to the screen:
5. Define a structure Rectangle with two members: length and width. Ask the user 
to input the length and width of a rectangle. Calculate and output the area and 
perimeter of the rectangle.
Input: 
Output:
6. Define a structure Student with the following members:
⚫ name (a string)
⚫ roll_number (an integer)
⚫ marks (a float)
Write a program to:
⚫ Declare an array of 3 Student structures.
⚫ Ask the user to input the details of each student.
⚫ Print the name and marks of the student with the highest marks.
Input: 
‘Output: 
--- Student with Highest Marks ---
Name: Eva 
Marks: 90.00
7. Write a C program that defines a Student structure with fields for name and 
age. Create an array of students, populate it with sample data, and sort the 
array by student names in alphabetical order.
Instructions:
1. Define a Structure:
• Create a struct named Student with the following members:
• char name[50]; to store the student's name.
• int age; to store the student's age.
2. Create an Array of Structures:
• Define an array of Student structures to store information for at 
least 5 students.
3. Populate the Array:
• Initialize the array with sample data for student names and ages.
4. Sort the Array:
• Write a function to sort the array by student names in alphabetical 
order using a suitable sorting algorithm.
5. Print the Sorted Array:
• Display the sorted list of students, including their names and age.
Input: 
Student 1: 
Name: Tom
Age: 32
Student 2:
Name: Dick
Age: 43
Student 3:
Name: Jane
Age: 24
Output:
Dick: 43
Jane: 24
Tom: 32

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值