Jump to content

Peter_APIIT

Members
  • Posts

    69
  • Joined

  • Last visited

Contact Methods

  • MSN
    peter_wkc_20@hotmail.com
  • Website URL
    http://

Peter_APIIT's Achievements

casual

casual (2/7)

0

Reputation

  1. Actually, what i want to do is i would like to calculate the days between two date. A date enter by user and a initialized date. calculate the different between two date and divide % 7 and return the remainder, determine the days of week such as monday or sunday.
  2. Hello everyone, Any recommendations or idea is greatly appreciated by me and others? Thanks for your help.
  3. Hello all of you, i totally a newbie to programming,linux and computer also. I wrote a program which calulate the days between the initlized date and date enter by user. After calculated, rreturn the days of week. Unfortunately, the calulation is not working. Any idea or recommendations ? Your help is greatly appreciated by me and others. /* * File: Date.c * Author: nicholas_tse * * Created on March 18, 2007, 7:56 PM */ #include <stdio.h> #include <stdlib.h> #include "Date.h" int Days_Of_Week(const struct U_Days *, const struct U_Months *, const struct U_Years *); int main(int argc, char** argv[]) { static struct Days days = {1}; static struct Months months = {1}; static struct Years years = {2002}; // --------------------------------------------------- char *Date[7]= {"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday" }; // --------------------------------------------------- int result; struct U_Days *days_ptr; struct U_Months *months_ptr; struct U_Years *years_ptr; days_ptr = &u_days; months_ptr = &u_months; years_ptr = &u_years; // -------------------------------------------------- do { printf("Enter a day in integer: "); scanf("%d", &days_ptr->days); printf("Enter a month in integer: "); scanf("%d", &months_ptr->months); printf("Enter a year in integer: "); scanf("%d", &years_ptr->years); result = Days_Of_Week(days_ptr, months_ptr, years_ptr); printf("\nThe date your enter equal to days of week is %s\n\n", Date[result]); }while(days_ptr->days >0 && days_ptr->days <32 || months_ptr->months >0 && months_ptr->months <13); return (EXIT_SUCCESS); } // ----------------------------------------------------- int Days_Of_Week(const struct U_Days *days_ptr, const struct U_Months *months_ptr, const struct U_Years *years_ptr) { static struct Days days = {1}; static struct Months months = {1}; static struct Years years = {2002}; // ----------------------------------------------------- char *Date[7] = {"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday" }; int days_of_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int loop; int temp_days; int k; // ------------------------------------------------------ if (years_ptr->years % 4 ==0) { days_of_month[1] = 29; } else { days_of_month[1] = 28; } for (k=0; days_of_month[k]<12; k++) { temp_days = temp_days + days_of_month[k]; } // Why here the the loop won't calculate the total days; printf("\n%d", days_of_month[3]); printf("\nTotal of days is %d", temp_days); if (days_ptr->days % 7 == 1) { return 0; } else if (days_ptr->days % 7 == 2) { return 1; } else if (days_ptr->days % 7 == 3) { return 2; } else if (days_ptr->days % 7 == 4) { return 3; } else if (days_ptr->days % 7 == 5) { return 4; } else if (days_ptr->days % 7 == 6) { return 5; } else if (days_ptr->days % 7 == 0) { return 6; } } /* * File: Date.h * Author: nicholas_tse * * Created on March 18, 2007, 9:27 PM */ #ifndef _Date_H #define _Date_H struct U_Days { int days; }u_days; struct U_Months { int months; }u_months; struct U_Years { int years; }u_years; // ---------------------------------------------------- static struct Days { int days; }days; static struct Months { int months; }months; static struct Years { int years; }years; #endif /* _Date_H */
  4. I have a math.c file which uses the pow function from math.h but cannot run the project. I don't know what happen. Below is my math.c file: /* program to print a table of powers */ #include <stdio.h> /* this header file includes the pow() function */ #include <math.h> int main() { int num; float rn; printf("Type in a number\n"); scanf ("%d",&num); printf("\nHere is a table for the square\n"); printf("cube, quartic and quintic for %d to %d:\n\n", num, num+4); printf("Integer\tSquare\tCube\tQuartic\tQuintic\n"); /* if read in as int must be converted to float for pow() */ rn=num; /* each specifier includes the same width as header, no decimal places with following tab*/ printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n", rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++; printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n", rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++; printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n", rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++; printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n", rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++; printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n", rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); return 0; } Thanks for your help. Your help is greatly appreciated by me and others.
  5. My connection type is connect to the internet through a router. My router is ZyXEL p-334WT. My connection type is ADSL.
  6. I have the mandriva linux 2007 installed in my computer. I unable to start the netlink at boot time. I odn't know how to solve it by changing the configurations files. Thanks for your help. Your help is greatly appreciated by me and others.
  7. I have downloaded the ktorrent and libktorrent but i cannot install it failed dependencies due to glibc crash. I have heard that glibc developed by Red Hat has many issues. I don't know how to solve this. I have try typed urpmi ktorrent but also failed dependencies. I have try typed urpmi glibc and it displayed already installed. I was wonder what the terminal complaint that failed dependencies since i have glibc. libkotterent relate some of the functions from glibc. Your help is greatly appreciately by me. Thanks for your help.
  8. I have did it according to what you say but also cannot solved it .
  9. NETWORKING=yes GATEWAY=192.168.1.1 HOSTNAME=nicholas_tse.nicholas_tse_proxy_server nichola s_tse Above is my /etc/sysconfig/netowork configuration files. I realised that when shut down computer, it cannot shutdown the postgrel because nicholas_tse host name is not there. Your help is greatly appreciated. How to permanently change the hostname because each i shut down and restart again it display the same host name which localhost. Thanks for your help,
  10. I just guess just is it have to configure the /etc/squid/squid.confg ? acl somethinglike that.
  11. Below is my /etc/sysconfig/network NETWORKING=yes GATEWAY=192.168.1.1 HOSTNAME=nicholas_tse.nicholas_tse_proxy_server nicholas_tse and /etc/hosts 127.0.0.1 nicholas_tse.nicholas_tse_proxy_server nicholas_tse I have did what you told me but still can't connect to internet through proxy server. I configuredmy browser proxy server is nicholas_tse_proxy_server. Is it have to register a domain before set up a proxy server ?
  12. My /etc/hosts file is as below: 127.0.0.1 nicholastse.org I want to put my domain name as APIIT.edu.my. Please help in this. I really is a stupid guy. Therefore, please forgive my stupidness. Your help is greatly appreciated by me and others who view this post. I hope that linux will become the no 1 choice among the computer consumers. Besides that, i also hope that GOD will blessed you.
  13. I have did according what you tell me. I have edit the file /etc/sysconfig/network. I added this line HOSTNAME=nicholastse.org to that file. Unfortunately, the browser complaint that unknown proxy host - . Is it have to register a domain first before it can set up a proxy server ? If not, then why is so many problem to set up a proxy server. Below is my /etc/sysconfig /network configuration file NETWORKING=yes HOSTNAME=nicholastse.org Please help in this issue. I know you are a great guy. Your help is greatly appreciated by me and others. I using konqueror as my web browser. I have changed the settings which is manually specify the proxy settings and automatic detect proxy settings. When i changed it to automatic, it displayed an error message which is could not find a usable proxy configuration script. I hope this will help. If you need more information, please let me know.
×
×
  • Create New...