lab4C.c file contains:
#include <stdio.h> ..... #define SIZE 10 #define SIZE2 40 int main(int argc, char *argv[]) { char input[SIZE2]; char name[SIZE]; .... char resu[SIZE2], resu2[SIZE2], resu3[SIZE2]; printf("Enter name, age and wage (exit to quit): "); fgets(input, 40, stdin); while (...) { /* use fgets to read again */ printf("Enter name, age and wage (exit to quit): "); fgets(input, 40, stdin); } return 0; }
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdlib.h>
int main(void)
{
char name[20];
int age;
float wage;
char newAge[5];
char newWage[5];
char input[40];
char resu[40] = "";
char resu2[40] = "";
char resu3[40] = "";
float floorValue, ceilValue;
char floors[5], ceils[5];
while(strcmp(input, "exit") != 10)
{
printf("Enter name, age and wage (exit to quit): ");
fgets(input, 40, stdin);
if(strcmp(input, "exit") == 10)
{
printf("\nGood Bye!\n");
exit(0);
}
else
{
sscanf(input, "%s %d %f", name, &age, &wage);
name[0] = toupper(name[0]);
age += 10;
wage += wage;
floorValue = floor(wage);
ceilValue = ceil(wage);
strcat(resu, name);
strcat(resu, "-");
sprintf(newAge, "%d", age);
strcat(resu, newAge);
strcat(resu, "-");
sprintf(newWage, "%0.3f", wage);
strcat(resu, newWage);
strcat(resu, "-[");
sprintf(floors, "%d", (int)floorValue);
strcat(resu, floors);
strcat(resu, ", ");
sprintf(ceils, "%d", (int)ceilValue);
strcat(resu, ceils);
strcat(resu, "]");
strcpy(resu2, resu);
sprintf(resu3, resu, "");
printf("%s\n", resu);
printf("%s\n", resu2);
printf("%s\n", resu3);
printf("\n");
strcpy(resu, "");
strcpy(resu2, "");
strcpy(resu3, "");
}
}
return 0;
}
********************************************************************* SCREENSHOT ******************************************************
lab4C.c file contains: #include <stdio.h> ..... #define SIZE 10 #define SIZE2 40 int main(int argc, char *argv...
#include <stdlib.h> #include <stdio.h> #include "main.h" #define MAX_NUM_LENGTH 11 void usage(int argc, char** argv) { if(argc < 4) { fprintf(stderr, "usage: %s <input file 1> <input file 2> <output file>\n", argv[0]); exit(EXIT_FAILURE); } } /* This function takes in the two input file names (stored in argv) and determines the number of integers in each file. If the two files both have N integers, return N, otherwise return -1. If one or both of the files do not exist, it...
#include <stdio.h> .. int main(int argc, char *argv[]) { int base, power; printf("enter base and power: "); scanf("%d %d", &base, &power); while (base != -100){ double res = pow(base, power); double res2 = my_pow(base, power); printf("pow: %.4f\n", res); printf("my_pow: %.4f\n", res2); .... } return 0; } // this function should be RECURSIVE // should not use any loop here double my_pow(double base, double p) { } lab4pow.c file contains: 2.1 Specification Write an ANSI-C program that reads input from the...