Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For C++ in visual studio, in scanf, printf, getschar, format. not C<<in>>, thank

ID: 666029 • Letter: F

Question

For C++ in visual studio, in scanf, printf, getschar, format. not C<<in>>, thank you!

Write a program or function for each of the following. If you write a function, make sure you have a main program that tests the function. Include code and a sample run for each problem.

Write a program that 3creates a structure (a C struct) to hold student information. The information should include Last Name, First Name, Number of credits completed, and Date of enrollment. The main program should allow the user to enter information on a student and then print out the information that was entered.

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>
#include <time.h>


void main(int argc, char* argv[]) {

const int TRIALS = 100000;
int trial;
int die;
static int rolls = 0;
static int totalRolls = 0;
double x;

srand(time(0));

for (trial = 0; trial < TRIALS; ++trial) {
    while (rolls != 4) {
    die = (rand() % 6 + 1); //probability of dies with 6 faces
    ++totalRolls;
    if (die == 3) {
    ++rolls;
    }
    else {
        rolls = 0;
    }

}
}
x = (totalRolls / TRIALS);
printf("%d ", totalRolls);
printf("%.2lf", x);
getchar();
getchar();
}

#include <stdio.h>
#include <string.h>
// Last Name, First Name, Number of credits completed, and Date of enrollment.

struct student
{
            int id,credits_comp;
            char fname[20],lname[20],dateofEnr[20];
            float percentage;
};

void func(struct student record);

int main()
{
            struct student record;

            record.id=1;
            strcpy(record.fname, "Raju");
           strcpy(record.lname, "david");
            record.credits_comp=4;
           strcpy(record.dateofEnr, "aug82015");
            record.percentage = 86.5;

            func(record);
            return 0;
}

void func(struct student record)
{
            printf(" Id is: %d ", record.id);
            printf(" Name is: %s ", record.fname"+"record.lname);
           printf(" credits completed ",record.credits_comp);
           printf("Date of enroll ment ",record.dateofEnr);
            printf(" Percentage is: %f ", record.percentage);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote