Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Array String

The document discusses a student's programming activity involving arrays, strings, user input, and memory addresses. It includes the student's codes, output, and documentation of their programming work.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Array String

The document discusses a student's programming activity involving arrays, strings, user input, and memory addresses. It includes the student's codes, output, and documentation of their programming work.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

DELA CRUZ, RIA DIVINE T.

2021-10772
EIT 0329.1-1 (COMPUTER FUNDAMENTALS AND PROGRAMMING)
Hands-On Activity 6: Array, String, User Input & Memory Address

• PROGRAMMING CODES (Print Screen)


• PROGRAMMING CODES (Print Screen)
• PROGRAMMING CODES (Print Screen)

• OUTPUT (PRINT SCREEN)


• OUTPUT (PRINT SCREEN)
• OUTPUT (PRINT SCREEN)

• PROGRAMMING CODES
#include <stdio.h>

int main() {

//TOPIC: Array

//For Access
printf("ACCESS THE ELEMENTS OF ARRAY\n");
printf("Grades:\n");
int Grades[] = {96, 95, 98, 97, 93, 94, 99, 90};

printf("%d\n", Grades[0]);
printf("%d\n", Grades[2]);
printf("%d\n", Grades[4]);
printf("%d\n\n", Grades[6]);

//For Change
printf("CHANGE AN ARRAY ELEMENT\n");
printf("Highest Grade:\n");
int grades[] = {96, 95, 98, 97, 93, 94, 99, 90};
grades[6] = 100;
printf("%d\n\n", grades[6]);

//For Loop
printf("LOOP THROUGH AN ARRAY\n");
printf("Units:\n");
int units[] = {3, 1, 2, 3, 1, 1};
int x;

for (x = 0; x < 4; x++) {


printf("%d\n", units[x]);
}

//For Size
printf("\n");
printf("SET ARRAY SIZE\n");
printf("Units:\n");
int gwa[3];

gwa[0] = 96;
gwa[1] = 98;
gwa[2] = 97;

printf("%d\n\n", gwa[0]);

//TOPIC: STRINGS
printf("STRINGS\n");
char greetings[] = "Good day, BSME!";
printf("%s\n\n", greetings);

//For Access
printf("ACCESS STRINGS\n");
char hello[] = "Good day, BSME!";
printf("%c\n\n", hello[0]);

//For Modify
printf("MODIFY STRINGS\n");
char ciao[] = "Good day, BSME!";
ciao[12] = 'C';
printf("%s\n\n", ciao);

//For Differences
printf("DIFFERENCES\n");
char jour[] = "Good day, BSME!";
char jour2[] = {'G', 'o', 'o', 'd', ' ', 'd', 'a', 'y', ' ', ',', 'B', 'S', 'M', 'E', '!', '\0'};
printf("%lu\n", sizeof(jour));
printf("%lu\n\n", sizeof(jour2));

return 0;
}
• PROGRAMMING CODES
#include <stdio.h>

int main() {
// TOPIC: USER INPUT

// Student Information
int studNum[10];
char lastName[30];
char firstName[30];
char middleName[30];
char gen[10];
char status[20];
char studType[20];
char regStatus[20];
char college[10];
char degreeProg[10];
int year[1];
char plmEmail[30];
char enrollStat[20];

printf("Student Number:");
scanf("%d", &studNum);

printf("Last Name:");
scanf("%s", lastName);

printf("First Name:");
scanf("%s", firstName);
printf("Middle Name:");
scanf("%s", middleName);

printf("Gender:");
scanf("%s", gen);

printf("Civil Status:");
scanf("%s", status);

printf("Student Type:");
scanf("%s", studType);

printf("Registration Status:");
scanf("%s", regStatus);

printf("College:");
scanf("%s", college);

printf("Degree Program:");
scanf("%s", degreeProg);

printf("Year Level:");
scanf("%d", &year);

printf("PLM Email:");
scanf("%s", plmEmail);
printf("Enrollment Status:");
scanf("%s", enrollStat);

// Grades
printf("\n\n\n\n");
printf("GRADES\n");

float eda;
float engma;
float drb;
float belec;
float belab;
float thermo;
float mst;
float advm;
float ppc;
float pe;

printf("Engineering Data Analysis:\t");


scanf("%f", &eda);

printf("Engineering Management:\t");
scanf("%f", &engma);

printf("Dynamics of Rigid Bodies:\t");


scanf("%f", &drb);
printf("Basic Electronics (Lec):\t");
scanf("%f", &belec);

printf("Basic Electronics (Lab):\t");


scanf("%f", &belab);

printf("Thermodynamics 2:\t");
scanf("%f", &thermo);

printf("Machine Shop Theory:\t");


scanf("%f", &mst);

printf("Advanced Mathematics for ME:\t");


scanf("%f", &advm);

printf("Philippine Popular Culture:\t");


scanf("%f", &ppc);

printf("Group Exercise:\t");
scanf("%f", &pe);

float SUM = eda+engma+drb+belec+belab+thermo+mst+advm+ppc+pe;


SUM /= 10;
printf("General Weighted Average: %0.2f", SUM);

return 0;
}
• PROGRAMMING CODES
#include <stdio.h>

int main() {

//TOPIC: MEMORY ADDRESS


printf("MEMORY ADDRESS\n");
int age = 20;
printf("%p\n", &age);

return 0;
}

• OUTPUT
ACCESS THE ELEMENTS OF ARRAY
Grades:
96
98
93
99

CHANGE AN ARRAY ELEMENT


Highest Grade:
100

LOOP THROUGH AN ARRAY


Units:
3
1
2
3

SET ARRAY SIZE


Units:
96

STRINGS
Good day, BSME!

ACCESS STRINGS
G

MODIFY STRINGS
Good day, BSCE!

DIFFERENCES
16
16
• OUTPUT
Student Number:202110772
Last Name:DelaCruz
First Name:RiaDivine
Middle Name:Taneo
Gender:Female
Civil Status:Single
Student Type:Old
Registration Status:Regular
College:CET
Degree Program:BSME
Year Level:3
PLM Email:rdtdelacruz2021@plm.edu.ph
Enrollment Status:Enrolled
GRADES
Engineering Data Analysis: 1.5
Engineering Management: 1
Dynamics of Rigid Bodies: 2.5
Basic Electronics (Lec): 1
Basic Electronics (Lab): 1.5
Thermodynamics 2: 1.25
Machine Shop Theory: 1.5
Advanced Mathematics for ME: 1
Philippine Popular Culture: 1.75
Group Exercise: 1
General Weighted Average: 1.40

• OUTPUT
MEMORY ADDRESS
0x7ffea80cb1fc

You might also like