Student Record Management System



/*
**Name:             Mark Anthony A. Cabanlit
**Student Number:   2010-35479
**Date Began:       October 2, 2010
**Date Finished:    October 12, 2010
**File description: The student Record Management System (SRMS) is an array-based
                            application used to register, view, modify and/or delete
                            student records.
*/

#include "Prototype.h"

int main(void)
{

    introSRMS();

    for(;;)//allows the program to continue and it only stops if the user wants it to.
    {
        overall();
    }

    return 0;
}

int modifyGet(void)
{
    int modifyNumber;
    int limit;
    int u = -1;
    int i;

    limit = vacantSlots();//get the number of students inside the struct

    if(limit == 0)//checks if there are already datas inside the struct
    {
        printf("\nNo data ENTRIES available!");
        printf("\nRedirecting to main.");
        overall();
    }
    else
    {
    printf("\n\tEnter student number:");
    scanf("%i", &modifyNumber);

        for(i = 0; i < limit; i++)
        {
            if (modifyNumber == stud[i].stud_number)//searches the location of the given student number
            {
                u = i;
                break;
            }
            else
            {
                u = -1;
            }

        }

        return u;
   }

}

void modifyMain(void)
{
    int x;
    int modifyChoice;
    int limit;

    limit = vacantSlots();

    x = modifyGet();

    if (x == -1)//checks if the student number exists
    {
        printf("\n\t\tStudent does not exist!");
        printf("\n\t\tRedirecting to main.");
        overall();
    }
    else if (limit > 0)//falsified when there is no entry inside the structure
    {
    printf("\n\tWhat would you like to modify from %s?", stud[x].first_name);
    space();

    printf("\n\t\t1. Modify All");
    printf("\n\t\t2. Modify Last Name");
    printf("\n\t\t3. Modify First Name");
    printf("\n\t\t4. Modify Birthdate");
    printf("\n\t\t5. Modify Course");
    printf("\n\t\t6. Go back to main.");

    space();
    printf("\n\t\tEnter choice:");
    scanf("%i", &modifyChoice);
    fflush(stdin);

    switch (modifyChoice)
    {
        case 1: space();
                printf("\n-----------------------------------Modify All-----------------------------------");
                space();
                modifyAll(x);
                break;

        case 2: space();
                printf("\n--------------------------------Modify Last Name--------------------------------");
                space();
                modifyLast(x);
                break;

        case 3: space();
                printf("\n--------------------------------Modify First Name-------------------------------");
                space();
                modifyFirst(x);
                break;

        case 4: space();
                printf("\n--------------------------------Modify Birth Date-------------------------------");
                space();
                modifyBirthday(x);
                break;

        case 5: space();
                printf("\n----------------------------------Modify Course---------------------------------");
                space();
                modifyCourse(x);
                break;

        case 6: space();
                overall();
                break;

        default: printf("\nInvalid Choice:");
                 space();
                 printf("\nRedirected to main.");
                 overall();

    }
    }

}

void modifyLast(int i)
{
    printf("\n\tEnter new last name:");
    scanf("%s", &stud[i].last_name);
}

void modifyFirst(int i)
{
    printf("\n\tEnter new first name:");
    scanf("%s", &stud[i].first_name);
}

void modifyCourse(int i)
{
    printf("\n\tEnter new course:");
    scanf("%s", &stud[i].course);
}

void modifyBirthday(int i)
{
    printf("\n\tEnter new birthday (yyyy-mm-dd):");
    scanf("%s", &stud[i].birthday);
}

void modifyAll(int i)
{
    int j;
    int count = 0;
    int number;

    if (i > 0)//will only be true if there are data inside the struct
    {
    printf("\n\tEnter new student number:");
    scanf("%i", &number);
    for(j = 0; j < i; j++)
    {
        if (number == stud[j].stud_number)
        {
            printf("\nStudent number already taken!!");
            count = count + i;
            break;
        }
        else
        {
            count--;
        }
    }
    if (count < 0)//continuation after the verification of student number
    {
        stud[i].stud_number = number;

        printf("\n\tEnter new last name:");
        scanf("%s", &stud[i].last_name);

        printf("\n\tEnter new first name:");
        scanf("%s", &stud[i].first_name);

        printf("\n\tEnter new birthday (yyyy-mm-dd):");
        scanf("%s", &stud[i].birthday);

        printf("\n\tEnter new course:");
        scanf("%s", &stud[i].course);
    }
    }
    else
    {
        printf("\n\tEnter new student number:");
        scanf("%i", &stud[i].stud_number);

        printf("\n\tEnter new last name:");
        scanf("%s", &stud[i].last_name);

        printf("\n\tEnter new first name:");
        scanf("%s", &stud[i].first_name);

        printf("\n\tEnter new birthday (yyyy-mm-dd):");
        scanf("%s", &stud[i].birthday);

        printf("\n\tEnter new course:");
        scanf("%s", &stud[i].course);
    }

}

void eraseMain(void)
{
    int eraseChoice;

    printf("\n\tWhat would you like to erase");
    space();
    printf("\n\t\t1. Delete all");
    printf("\n\t\t2. Delete one");
    printf("\n\t\t3. Go back to main");
    space();
    printf("\n\tEnter your choice:");
    scanf("%i", &eraseChoice);
    fflush(stdin);

    switch (eraseChoice)
    {
        case 1: printf("\n-------------------------------Delete all Students------------------------------");
                space();
                eraseAll();
                break;

        case 2: printf("\n---------------------------------Delete a Student-------------------------------");
                space();
                eraseOne();
                break;
        case 3: overall();

        default: printf("\nInvalid Choice");
    }
}

void eraseOne(void)
{
    int u = -1;//signals if the student does not exist
    int i;
    int v;
    int limit;
    int search;

    printf("\n\tEnter the student number:");
    scanf("%i", &search);

    limit = vacantSlots();

    for(i = 0; i < limit; i++)
    {
        if (search == stud[i].stud_number)//checks if the imputed student number is available
        {
            u = i;
            break;
        }

    }

    if (u < 0)
    {
        printf("\nStudent does NOT exist!!");
    }
    else if (u == i)//makes sure that u is equal to i
    {
        printf("\nEntries about %s has been deleted.", stud[u].first_name);

        stud[u].stud_number = '\0';
        stud[u].last_name[0] = '\0';
        stud[u].first_name[0] = '\0';
        stud[u].birthday[0] = '\0';
        stud[u].course[0] = '\0';

       for(u = i; u < limit; u++)//enables the datas next to the deleted data to fill up the missing areas
        {
            stud[u].stud_number = stud[u+1].stud_number;

            //loops the string in order for it to replace the missing ones
            for(v = 0; v < strlen(stud[u].last_name)+1; v++)
            {
                stud[u].last_name[v] = stud[u+1].last_name[v];
            }

            for(v = 0; v < strlen(stud[u].first_name)+1; v++)
            {
                stud[u].first_name[v] = stud[u+1].first_name[v];
            }

            for(v = 0; v < strlen(stud[u].birthday)+1; v++)
            {
                stud[u].birthday[v] = stud[u+1].birthday[v];
            }

            for(v = 0; v < strlen(stud[u].course)+1; v++)
            {
                stud[u].course[v] = stud[u+1].course[v];
            }
        }

    }

}

void eraseAll(void)
{
    char eraseLetter;
    int limit;
    int j;

    limit = vacantSlots();//gets the number of students inside the struct

    printf("Are you sure you want to delete all the information?");
    printf("\nEnter y for YES and n for NO:");
    fflush(stdin);
    eraseLetter = getchar();

    if (eraseLetter == 'y')
    {
        for(j = 0; j < limit; j++)
        {
            //makes all the values to null
            stud[j].stud_number = '\0';
            stud[j].last_name[0] = '\0';
            stud[j].first_name[0] = '\0';
            stud[j].birthday[0] = '\0';
            stud[j].course[0] = '\0';
        }
        printf("\nAll entries have been deleted!");

    }
    if (eraseLetter == 'n')
    {
        space();
        printf("\nRedirecting to main.");
        overall();
    }
    if ((eraseLetter != 'y') && (eraseLetter != 'n'))
    {
        space();
        printf("\nInvalid choice");
        printf("\nRedirecting to main.");
        overall();
    }

}

void inputValues(void)
{
    int i;
    int j;
    int flag = 0;

    i = vacantSlots();

    space();
    printf("\nEnter student information.");
    space();

    printf("\n\tEnter Student Number:");
    scanf("%i", &stud[i].stud_number);

    if (i != 0)//does not work if the struct is empty
    {
        for(j = 0; j < i; j++)
        {
            if (stud[i].stud_number == stud[j].stud_number)
            {
                //turns all the inputed values to null to make sure it does not
                    //mess with the program
                stud[i].stud_number = '\0';
                stud[i].last_name[0] = '\0';
                stud[i].first_name[0] = '\0';
                stud[i].birthday[0] = '\0';
                stud[i].course[0] = '\0';
                printf("\nStudent number already taken!!");
                flag = flag + i;//signal that the student number is already taken
                break;
            }
            else
            {
                flag--;//signals that the student number is not taken
            }
        }
    }
    else//satisfies the condition that if i is 0
    {
        printf("\n\tEnter last name:");
        scanf("\n%s", stud[i].last_name);

        printf("\n\tEnter first name:");
        scanf("%s", stud[i].first_name);

        printf("\n\tEnter birthday (yyyy-mm-dd):");
        scanf("%s", stud[i].birthday);

        printf("\n\tEnter course:");
        scanf(" %s", stud[i].course);

    }

    if (flag < 0)//continuation for flag--
    {
        printf("\n\tEnter last name:");
        scanf("%s", stud[i].last_name);

        printf("\n\tEnter first name:");
        scanf("%s", stud[i].first_name);

        printf("\n\tEnter birthday (yyyy-mm-dd):");
        scanf("%s", stud[i].birthday);

        printf("\n\tEnter course:");
        scanf("%s", stud[i].course);
    }

}

int vacantSlots(void)
{
    int v;

    //loops until stud[v].stud_number has a null value.
    //loops until v is equal to MAX
    for(v = 0; stud[v].stud_number && v < MAX; ++v)
    {
        continue;
    }

    if(v == MAX)
    {
        return -1;
    }
    return v;
}

void displayMain(void)
{
    int displayChoice;

    printf("\n\tWhat would you like to display?");
    space();
    printf("\n\t\t1. Display all");
    printf("\n\t\t2. Display one");
    printf("\n\t\t3. Go back to main");
    space();
    printf("\n\tEnter your choice:");
    scanf("%i", &displayChoice);
    fflush(stdin);

    switch (displayChoice)
    {
        case 1: printf("\n-------------------------------Display all Students-----------------------------");
                space();
                displayAll();
                break;

        case 2: printf("\n---------------------------------Display a Student------------------------------");
                space();
                displayOne();
                break;
        case 3: overall();

        default: printf("\nInvalid Choice");
    }
}

void displayAll(void)
{
    int u;
    int x = 0;
    int limit;

    bubbleSort(stud);

    space();
    space();

    printf("\n  Student No. |   Last Name   |   First Name   |   Birthday   |   Course ");
    space();
    space();

    limit = vacantSlots();//gets the number of students inside struct

    for(u = 0; u < limit; u++)
    {
        printf("   %i", stud[u].stud_number);
        printf("\t  %s", stud[u].last_name);
        printf("\t   %s", stud[u].first_name);
        printf("\t  %s", stud[u].birthday);
        printf("\t   %s", stud[u].course);
        space();
        space();

        //if you want the arrays to be aligned left, use the code below
        /*printf("%12i", stud[u].stud_number);
        printf("%15s", stud[u].last_name);
        printf("%17s", stud[u].first_name);
        printf("%15s", stud[u].birthday);
        printf("%15s", stud[u].course);*/
    }

}

void displayOne(void)
{
    int u = -1;
    int i;
    int limit;
    int search;

    printf("\n\tEnter the student number:");
    scanf("%i", &search);

    limit = vacantSlots();

    for(i = 0; i < limit; i++)
    {
        if (search == stud[i].stud_number)//verifies if the student number exists
        {
            u = i;
            break;
        }

    }

    if (u < 0)
    {
        printf("\nStudent does NOT exist!!");
    }
    else
    {
    printf("\n  Student No. |   Last Name   |   First Name   |   Birthday   |   Course ");

    space();
    space();

    printf("   %i", stud[u].stud_number);
    printf("\t  %s", stud[u].last_name);
    printf("\t   %s", stud[u].first_name);
    printf("\t  %s", stud[u].birthday);
    printf("\t   %s", stud[u].course);
    space();
    space();

     //if you want the arrays to be aligned left, use the code below
    /*printf("%12i", stud[u].stud_number);
    printf("%15s", stud[u].last_name);
    printf("%17s", stud[u].first_name);
    printf("%15s", stud[u].birthday);
    printf("%15s", stud[u].course);*/

    }

}

void introSRMS(void)
{
    space();
    space();
    printf("-------------------------STUDENT RECORD MANAGEMENT SYSTEM-----------------------");
    space();
    printf("\nThe student Record Management System (SRMS) is an array-based application used ");
    printf("\nto register, view, modify and/or delete student records.");
    space();

    loadArray(stud);
}

int choiceMain(void)
{
    int choice_Main;
    int limit;

    space();
    space();
    printf("--------------------------------------MAIN--------------------------------------");
    space();

    printf("\nWhat would you like to do?");
    space();
    printf("\n1. Add Student");
    printf("\n2. Modify Student");
    printf("\n3. Display");
    printf("\n4. Delete");
    printf("\n5. Exit");
    space();

    printf("\nPlease enter your choice now:");
    scanf("%i", &choice_Main);
    fflush(stdin);

    return choice_Main;
}

void space(void)
{
    printf("\n");
}

void overall(void)
{
    int choice;
    int limit;

    limit = vacantSlots();
    choice = choiceMain();

    switch (choice)
    {
        case 1: space();
                printf("\n-----------------------------------Add Student----------------------------------");
                space();
                inputValues();
                break;

        case 2: space();
                printf("\n----------------------------------Modify Student--------------------------------");
                space();
                modifyMain();
                break;

        case 3: space();
                printf("\n---------------------------------Display Records--------------------------------");
                space();
                displayMain();
                break;

        case 4: space();
                printf("\n---------------------------------Delete Records---------------------------------");
                space();
                eraseMain();
                break;

        case 5: bubbleSort(stud);
                displayArray(stud);
                exit(0);
                break;

        default: printf("\nInvalid Input.");

    }
}

void displayArray(struct STUDENT stud[])
{
    FILE*fp;

    int i;
    int j;

    i = vacantSlots();

    STUDENT temp;

    fp = fopen("Records.txt","w");//opens records.txt
    //fprintf(fp,"%-12s %-12s %-12s %-12s %s\n","Student No.","Family Name","First Name","Birthdate","Course");

    for (j = 0; j < i; j++)
    {
        temp = stud[j];
        fprintf(fp,"%-12i %-12s %-12s %-12s %s\n",temp.stud_number,temp.last_name,temp.first_name,temp.birthday,temp.course);
    }
    fclose(fp);
}

void loadArray(struct STUDENT stud[])
{
    FILE *fp;
    int i;

    i = vacantSlots();

    STUDENT temp;

    fp = fopen("Records.txt", "r");//loads records.txt

    while (1)
    {
        fscanf(fp,"%i %s %s %s %s",&temp.stud_number, temp.last_name, temp.first_name, temp.birthday, temp.course);

        if (feof(fp))
        {
            break;
        }
        stud[i] = temp;
        i++;

        if(i > MAX)
        {
            printf("\nData is too large!");
            fclose(fp);
            exit(1);
        }
    }
    fclose(fp);
}

void bubbleSort(struct STUDENT stud[])
{
  int i, j;
  int limit;

  limit = vacantSlots();

  STUDENT temp;

  for (i = (limit - 1); i >= 0; i--)//counter
  {
    for (j = 1; j <= i; j++)//
    {
      if (stud[j].stud_number < stud[j-1].stud_number)//compares two members of the struct
      {
        temp = stud[j-1];//gives temp the value of the next element on struct
        stud[j-1] = stud[j];//gives the second value the first value
        stud[j] = temp;//final value of stud
      }
    }
  }
}

//Sources:
    //http://www.java2s.com/Code/C/Structure/Asimplemailinglistexampleusinganarrayofstructures.htm
        //for the vacantSlot function
    //http://kalyan-city.blogspot.com/2009/07/bubble-sorting-c-program-bubble-sort.html
        //for Bubble Sort
    //Mr. Chito Patiño
        //for all the lessons that he taught us specially on file handling

/*
201035479   Cabanlit    Mharkie     1993-09-23  BSCS
201035432   Bayon-on    James       1993-12-14  BSCS
201035458   Marikit     Peter       1993-01-29  BSCS
201035469   Lianza      Christian   1993-12-14  BAPS
201035471   Geronimo    Sarah       1995-65-23  BSMath
201045632   Fortalejo   Jewel       1995-65-13  BSGE
*/


Sneak Peak Of My Machine Problem

from the file prototype.h

 


/*
**Name:             Mark Anthony A. Cabanlit
**Student Number:   2010-35479
**Date Began:       October 2, 2010
**Date Finished:    October 12, 2010
**File description: This .h file contains all the function declarations
                        of Machine_Problem.c
*/

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

#define MAX 100

struct STUDENT {
    int stud_number;
    char last_name[30];
    char first_name[30];
    char birthday[30];
    char course[30];
}stud[MAX];

void overall();

/*
**Function Name:
**Function Description:
**Description of Parameters:
**Description of Return Value:
**Date Began:
**Date Finished:
*/

void introSRMS();
/*
**Function Name: introSRMS
**Function Description: Prints the name and description of the program.
**Description of Parameters: No parameters.
**Description of Return Value: No return value.
**Date Began: October 2, 2010
**Date Finished: October 2, 2010
*/

int choiceMain();
/*
**Function Name: choiceMain
**Function Description: Enables user to input his choice on
                            what to do with the program.
                            (e.g. Add, Modify, etc.)
**Description of Parameters: No parameters.
**Description of Return Value: int, value of selected operation.
**Date Began: October 2, 2010
**Date Finished: October 2, 2010
*/

int vacantSlots();
/*
**Function Name: vacantSlots
**Function Description: Checks the latest vacant value of the array of
                            structures. Somewhat the same with static int.
**Description of Parameters: No parameters.
**Description of Return Value: int, the number of students inside the
                            structure.
**Date Began: October 2, 2010
**Date Finished: October 3, 2010
*/

void inputValues();
/*
**Function Name: inputValues
**Function Description: Allows user to input the information of a student.
                            Prompts user if the student number already
                            exists.
**Description of Parameters: No parameters.
**Description of Return Value: No return value.
**Date Began: October 2, 2010
**Date Finished: October 4, 2010
*/

void modifyMain();
/*
**Function Name: modifyMain
**Function Description: Allows user to choose on what to modify.
**Description of Parameters: No parameters.
**Description of Return Value: No return value.
**Date Began: October 7, 2010
**Date Finished: October 7, 2010
*/

int modifyGet();
/*
**Function Name: modifyGet
**Function Description: Verifies the student number to be
                            modified by the user.
**Description of Parameters: No parameters.
**Description of Return Value: int, location of the student number if
                            it holds true but returns -1 if false.
**Date Began: October 7, 2010
**Date Finished: October 7, 2010
*/

void modifyAll(int);
/*
**Function Name: modifyAll
**Function Description: Modifies the student number, name, course
                            and birthday of a student given its student
                            number as input.
**Description of Parameters: int, the address of the student to be
                            modified.
**Description of Return Value: No return value.
**Date Began: October 7, 2010
**Date Finished: October 8, 2010
*/

void modifyLast(int);
/*
**Function Name: modifyLast
**Function Description: Modifies last name of a student given its student
                            number as input.
**Description of Parameters: No parameters.
**Description of Return Value: int, the address of the student to be
                            modified.
**Date Began: October 7, 2010
**Date Finished: October 7, 2010
*/

void modifyFirst(int);
/*
**Function Name: modifyFirst
**Function Description: Modifies first name of a student given its student
                            number as input.
**Description of Parameters: No parameters.
**Description of Return Value: int, the address of the student to be
                            modified.
**Date Began: October 7, 2010
**Date Finished: October 7, 2010
*/

void modifyCourse(int);
/*
**Function Name: modifyCourse
**Function Description: Modifies course of a student given its student
                            number as input.
**Description of Parameters: No parameters.
**Description of Return Value: int, the address of the student to be
                            modified.
**Date Began: October 7, 2010
**Date Finished: October 7, 2010
*/

void modifyBirthday(int);
/*
**Function Name: modifyBirthday
**Function Description: Modifies birthday of a student given its student
                            number as input.
**Description of Parameters: No parameters.
**Description of Return Value: int, the address of the student to be
                            modified.
**Date Began: October 7, 2010
**Date Finished: October 7, 2010
*/

void displayAll();
/*
**Function Name: displayAll
**Function Description: Dislays all the student number, first name,
                            family name, birthdate, and course.
**Description of Parameters: No parameters.
**Description of Return Value: No return value.
**Date Began: October 3, 2010
**Date Finished: October 4, 2010
*/

void displayOne();
/*
**Function Name: displayOne
**Function Description: Dislays the student number, first name,
                            family name, birthdate, and course
                            of a certain student given his student
                            number.
**Description of Parameters: No parameters.
**Description of Return Value: No return value.
**Date Began: October 3, 2010
**Date Finished: October 4, 2010
*/

void displayMain();
/*
**Function Name: displayMain
**Function Description: Allows user to select what to display.
**Description of Parameters: No parameters.
**Description of Return Value: No return value.
**Date Began: October 4, 2010
**Date Finished: October 4, 2010
*/

void eraseAll();
/*
**Function Name: eraseAll
**Function Description: Allows user to delete all datas inside
                            the program but before deleting, it asks
                            the user to confirm the said task.
**Description of Parameters: No parameters.
**Description of Return Value: No return value.
**Date Began: October 4, 2010
**Date Finished: October 5, 2010
*/

void eraseOne();
/*
**Function Name: eraseOne
**Function Description: Allows user to delete the information
                            of one student given his student number
                            and the function also prompts the user
                            if the student does not exist.
**Description of Parameters: No parameters.
**Description of Return Value: No return value.
**Date Began: October 5, 2010
**Date Finished: October 6, 2010
*/

void eraseMain();
/*
**Function Name:eraseMain
**Function Description: Allows user to select what to erase.
**Description of Parameters: No parameters.
**Description of Return Value: No return value.
**Date Began: October 6, 2010
**Date Finished: October 6, 2010
*/

void bubbleSort(struct STUDENT stud[], int);
/*
**Function Name: bubbleSort
**Function Description: Arranges the student numbers in
                            increasing order together with
                            their other attributes.
**Description of Parameters: struct, the main structure that
                            contains all the collected data.
                            int, size or the number of entries inside
                            the struct.
**Description of Return Value: No return value.
**Date Began: October 2, 2010
**Date Finished: October 12, 2010
*/

void loadArray(struct STUDENT stud[]);
/*
**Function Name: loadArray
**Function Description: Loads the array from records.txt to
                            the program.
**Description of Parameters: struct, the main struct used in the program.
**Description of Return Value: No return value.
**Date Began: October 9, 2010
**Date Finished: October 9, 2010
*/

void displayArray(struct STUDENT stud[]);
/*
**Function Name: displayArray
**Function Description: displays the information gathered from the
                            the program to records.txt
**Description of Parameters: struct, the main struct used in the program.
**Description of Return Value: No return value.
**Date Began: October 9, 2010
**Date Finished: October 9, 2010
*/

void space();
/*
**Function Name: space
**Function Description: Prints "\n" or enter.
**Description of Parameters: No parameters.
**Description of Return Value: No return value.
**Date Began: October 2, 2010
**Date Finished: October 2, 2010
*/


Pass or Fail (Problem 8)

#include <stdio.h>

int main(void)

{

float standing = 53;

float score, grade;

printf(“\nA program that determines whether a student passes (or fails) a subject given his/her last exam score.”);

printf(“\n”);

printf(“\nNote:”);

printf(“\n\tThe last exam has a total of 150 points.”);

printf(“\n\tThe student got a class standing of 53% prior to the last exam.”);

printf(“\n”);

printf(“\nEnter score for the last exam:”);

scanf(“%f”, &score);

if ((score < 0) || (score > 150))

{

printf(“\nINVALID SCORE!!”);

}

else

{

grade = (standing * 0.8) + (((score / 150)*100)*0.2);;

if (grade >= 60)

{

printf(“\nGrade = %f”, grade);

printf(“\n”);

printf(“\nPASS!!”);

}

else

{

printf(“\nGrade = %f”, grade);

printf(“\n”);

printf(“\nFAIL!!”);

}

}

return 0;

}

Age (Problem 7)

#include <stdio.h>

int main(void)

{

int month, year;

int agemonth, ageyear;

printf(“This program determines the exact age of a person this month given the person’s birthday.\n”);

printf(“\n”);

printf(” 1.January 4.April 7.July 10.October\n”);

printf(” 2.February 5.May 8.August 11.November\n”);

printf(” 3.March 6.June 9.September 12.December\n”);

printf(“\n”);

printf(“\n”);

printf(“\nPlease enter the number of your birthmonth (ie.1 for January):”);

scanf(“%i”,&month);

printf(“\nPlease enter the year of your birth (ie.1998):”);

scanf(“%i”,&year);

if (year<0)

{

printf(“\nINVALID YEAR!!”);

}

else

{

if ((month<=0) || (month>12))

{

printf(“\nINVALID MONTH!!”);

}

else

{

if ((month <= 8) && (month > 0))

{

agemonth = 8 – month;

ageyear = 2010 – year;

printf(“\n1Your age is %i years and %i months.”, ageyear, agemonth);

}

else

{

agemonth = (12 – month) + 8;

ageyear = 2009 – year;

printf(“\n2Your age is %i years and %i months.”, ageyear, agemonth);

}

}

}

return 0;

}

Jeepney Fare (Problem 6)

#include <stdio.h>

int main(void)

{

int distance;

float fare;

printf(“\nThis program determines the appropriate fare given the kilometers travelled by a passenger.”);

printf(“\n”);

printf(“\nEnter your distance travelled:”);

scanf(“%i”, &distance);

if (distance < 0)

{

printf(“\nInvalid Number!”);

}

else

{

if ((distance > 0) && (distance <= 5))

{

printf(“\nJeepney fare is PhP 6.50.”);

}

else

{

if (distance > 5)

{

fare = (6.50+((distance-5)*0.75));

printf(“\nJeepney fare is %.2f.”,fare);

}

else

{

if (distance == 0)

{

printf(“Zero distance = Zero fare.”);

}

}

}

}

return 0;

}

Raw Grade to 1-5 Grade System

#include <stdio.h>
int main(void)
{
int score;
int grade;
clrscr();
printf(“This program converts your grade to college grade.\n”);
printf(“Please enter grade(0-100):\n”);
scanf(“%i”,&score);
if (score<0)
{
printf(“The value %i is less than zero.”,score);
}
if (score>100)
{
printf(“The value %i is greater than one hundred.”,score);
}
else
{
if (score>=97)
{
if (score<=100)
{
printf(“Your grade is 1.00\n”);
}
}
if (score>=93)
{
if (score<=96)
{
printf(“Your grade is 1.25\n”);
}
}
if (score>=89)
{
if (score<=92)
{
printf(“Your grade is 1.50\n”);
}
}
if (score>=85)
{
if (score<=88)
{
printf(“Your grade is 1.75\n”);
}
}
if (score>=80)
{
if (score<=84)
{
printf(“Your grade is 2.00\n”);
}
}
if (score>=75)
{
if (score<=79)
{
printf(“Your grade is 2.25\n”);
}
}
if (score>=70)
{
if (score<=74)
{
printf(“Your grade is 2.50\n”);
}
}
if (score>=65)
{
if (score<=69)
{
printf(“Your grade is 2.75\n”);
}
}
if (score>=60)
{
if (score<=64)
{
printf(“Your grade is 3.00\n”);
}
}
if (score<60)
{
if (score>=0)
{
printf(“Your grade is 5.00\n”);
}
}
}
getch();
return 0;
}

#include <stdio.h>int main(void){int score;int grade;
clrscr();
printf(“This program converts your grade to college grade.\n”);printf(“Please enter grade(0-100):\n”);scanf(“%i”,&score);
if (score<0)     {     printf(“The value %i is less than zero.”,score);     }
if (score>100)     {     printf(“The value %i is greater than one hundred.”,score);     }
else     {     if (score>=97)      {      if (score<=100)           {           printf(“Your grade is 1.00\n”);           }      }
if (score>=93)      {      if (score<=96)           {           printf(“Your grade is 1.25\n”);           }      }     if (score>=89)      {      if (score<=92)           {           printf(“Your grade is 1.50\n”);           }      }     if (score>=85)      {      if (score<=88)           {           printf(“Your grade is 1.75\n”);           }      }     if (score>=80)      {      if (score<=84)           {           printf(“Your grade is 2.00\n”);           }      }     if (score>=75)      {      if (score<=79)           {           printf(“Your grade is 2.25\n”);           }      }     if (score>=70)      {      if (score<=74)           {           printf(“Your grade is 2.50\n”);           }      }     if (score>=65)      {      if (score<=69)           {           printf(“Your grade is 2.75\n”);           }      }     if (score>=60)      {      if (score<=64)           {           printf(“Your grade is 3.00\n”);           }
}     if (score<60)  {  if (score>=0)    {     printf(“Your grade is 5.00\n”);    }  }     }
getch();
return 0;
}

Least of the Three Numbers

#include <stdio.h>
int main(void)
{
int num1,num2,num3;
clrscr();
printf(“This program gets three numbers and displays the least among the three numbers.\n”);
printf(“\n”);
printf(“\tEnter first number : “);
scanf(“%i”,&num1);
printf(“\tEnter second number: “);
scanf(“%i”,&num2);
printf(“\tEnter third number : “);
scanf(“%i”,&num3);
printf(“\n”);
printf(“\n”);
printf(”     The three numbers are %i, %i and %i.”,num1,num2,num3);
printf(“\n”);
printf(“\n”);
if ((num1<num2) && (num1<num3))
{
printf(“\n\t 1The least number is %i.”,num1);
}
if ((num2<num1) && (num2<num3))
{
printf(“\n\t 2The least number is %i.”,num2);
}
if ((num3<num1) && (num3<num2))
{
printf(“\n\t 3The least number is %i.”,num3);
}
if ((num1==num2) && (num1<num3))
{
printf(“\n\t 4The least number is %i.”,num2);
}
if ((num3==num1) && (num3<num2))
{
printf(“\n\t 6The least number is %i.”,num1);
}
if ((num2==num3) && (num2<num1))
{
printf(“\n\t 8The least number is %i.”,num3);
}
if ((num1==num2) && (num2==num3))
{
printf(“\n\t The least number is %i.”,num1);
}
getch();
return 0;
}

#include <stdio.h>
int main(void){
int num1,num2,num3;
clrscr();
printf(“This program gets three numbers and displays the least among the three numbers.\n”);printf(“\n”);printf(“\tEnter first number : “);scanf(“%i”,&num1);
printf(“\tEnter second number: “);scanf(“%i”,&num2);
printf(“\tEnter third number : “);scanf(“%i”,&num3);
printf(“\n”);printf(“\n”);printf(”     The three numbers are %i, %i and %i.”,num1,num2,num3);printf(“\n”);printf(“\n”);
if ((num1<num2) && (num1<num3))     {     printf(“\n\t 1The least number is %i.”,num1);     }if ((num2<num1) && (num2<num3))     {     printf(“\n\t 2The least number is %i.”,num2);     }if ((num3<num1) && (num3<num2))     {     printf(“\n\t 3The least number is %i.”,num3);     }if ((num1==num2) && (num1<num3))     {     printf(“\n\t 4The least number is %i.”,num2);     }if ((num3==num1) && (num3<num2))     {     printf(“\n\t 6The least number is %i.”,num1);     }if ((num2==num3) && (num2<num1))     {     printf(“\n\t 8The least number is %i.”,num3);     }
if ((num1==num2) && (num2==num3))     {     printf(“\n\t The least number is %i.”,num1);     }getch();
return 0;
}

Area of Circle, Rectangle and Triangle

#include <stdio.h>
int main(void)
{
float circle,rectangle,triangle;
float x,y,radius,b,h;
float PI=3.1416;
int choice;
clrscr();
printf(“This program asks the user to choose among the following tasks.\n”);
printf(“1.Get the area of the circle\n”);
printf(“2.Get the area of a rectangle\n”);
printf(“3.Get the area of a triangle\n”);
printf(“\nPlease enter the number of your choice:\n”);
scanf(“%i”,&choice);
if (choice==1)
{
printf(“Enter radius:\n”);
scanf(“%f”,&radius);
circle = PI*(radius*radius);
printf(“The area of the circle with the radius %.2f is %.2f.\n”,radius,circle);
}
if (choice==2)
{
printf(“Enter length:\n”);
scanf(“%f”,&y);
printf(“Enter width:\n”);
scanf(“%f”,&x);
rectangle = x*y;
printf(“The area of the rectangle which has a length of %.2f and a width of %.2f is %.2f.\n”,y,x,rectangle);
}
if (choice==3)
{
printf(“Enter base:\n”);
scanf(“%f”,&b);
printf(“Enter height:\n”);
scanf(“%f”,&h);
triangle = ((b*h)/2);
printf(“The area of the triangle which has a base of %.2f and a height of %.2f is %.2f.\n”,b,h,triangle);
}
getch();
return 0;
}

#include <stdio.h>
int main(void){float circle,rectangle,triangle;float x,y,radius,b,h;float PI=3.1416;int choice;clrscr();printf(“This program asks the user to choose among the following tasks.\n”);printf(“1.Get the area of the circle\n”);printf(“2.Get the area of a rectangle\n”);printf(“3.Get the area of a triangle\n”);printf(“\nPlease enter the number of your choice:\n”);scanf(“%i”,&choice);
if (choice==1){printf(“Enter radius:\n”);scanf(“%f”,&radius);circle = PI*(radius*radius);printf(“The area of the circle with the radius %.2f is %.2f.\n”,radius,circle);
}
if (choice==2){printf(“Enter length:\n”);scanf(“%f”,&y);printf(“Enter width:\n”);scanf(“%f”,&x);rectangle = x*y;printf(“The area of the rectangle which has a length of %.2f and a width of %.2f is %.2f.\n”,y,x,rectangle);}
if (choice==3){printf(“Enter base:\n”);scanf(“%f”,&b);printf(“Enter height:\n”);scanf(“%f”,&h);triangle = ((b*h)/2);printf(“The area of the triangle which has a base of %.2f and a height of %.2f is %.2f.\n”,b,h,triangle);
}
getch();

return 0;}

Displays the Sum and Difference of the Squares of Two Numbers

#include <stdio.h>
int main(void)
{
float num1,num2;
float sum,difference;
clrscr();
printf(“This program displays the sum and difference of the squares of two numbers.\n”);
printf(“Enter first number:\n”);
scanf(“%f”,&num1);
printf(“Enter second number:\n”);
scanf(“%f”,&num2);
printf(“Your numbers are %.2f and %.2f.\n”,num1,num2);
sum = (num1*num1)+(num2*num2);
difference = (num1*num1)-(num2*num2);
printf(“The sum is %.2f and the difference is %.2f.\n”,sum,difference);
getch();
return 0;
}

#include <stdio.h>
int main(void){float num1,num2;float sum,difference;clrscr();
printf(“This program displays the sum and difference of the squares of two numbers.\n”);printf(“Enter first number:\n”);scanf(“%f”,&num1);printf(“Enter second number:\n”);scanf(“%f”,&num2);printf(“Your numbers are %.2f and %.2f.\n”,num1,num2);
sum = (num1*num1)+(num2*num2);difference = (num1*num1)-(num2*num2);
printf(“The sum is %.2f and the difference is %.2f.\n”,sum,difference);
getch();return 0;}

Spice Up Your College Life!!-a teaser

Based from my BFF’s tweets on twitter, they say na nagpipila pa daw sila upang makapag-enroll at makapag-choose sa kanilang subjects but I told them, “Mabuti pa dito sa UP, mayroom kaming online CHURVA!”. At nagtanong na naman itong friend ko kung ano yung “churva” at sinabi ko na “UPV-CRSIS“. At ito ang sinabi niya sa akin “BOBO ka teh! Acronym yan eh! paano ko malalaman kung ano yan?” kaya sinabi ko sa kanya na ang meaning nito ay “University of the Philippines Visayas – Computerized Registration Student Information System. At napasabi na lang ang friend ko ng “BONGGA’ at end of conversation na namin iyon. Deep inside, alam ko na walang na-intindihan ang friend ko from other school sa mga sinabi ko, that’s why I’m gonna tell you how its done. 🙂

The UPV-CRSIS aims to lessen the stress within our hearts during UP enrollment. It gives us quick access to …………………………

oi!!! Trailer pa lang toh..basahin ninyu ang aking true article here!