• Create or find 3 files containing C programs such as the one given below
#include <stdio.h>
struct time {
int hour,min;
};
typedef struct {
int flightno;
struct time arrival;
}FlightInfo;
void inp(FlightInfo arr[]){
int i;
for (i=0;i<2;i++)
{
printf("Enter flight no and arrival time:");
scanf("%d %d %d",&arr[i].flightno,&arr[i].arrival.hour,&arr[i].arrival.min);}}
void calculateDelay(FlightInfo arr[], int d){
int i,x;
for (i=0;i<2;i++) {
• For the three C programs,
◦ Read the file name from the user and open the file
◦ Read the C program from the text file and find the
▪ number of statements in the program
▪ number of for, while and do-while loops in the program
Output
Sample Run:
Program named “flights.cpp” contains:
53 lines of code
3 for loops
2 while loops
1 do-while loop
Program named “hw.cpp” contains:
45 lines of code
1 for loop
3 while loops
0 do-while loop
The answer to the question is available in the PDF file https://www.assignmentexpert.com/https://www.assignmentexpert.com/homework-answers/programming-answer-84049.pdf
Comments
Leave a comment