Link lit in c is a challenging lesson but I am grateful that I learned it.
it was such a practical lesson. Though I still prefer to program arrays, I still find dynamic memory allocation handy. I have learned techniques that are handy.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_C 200
typedef char string7[8];
typedef char string25[26];
typedef struct
{
string25 first, last;
char mid;
}nameType;
struct courseTag
{
string7 courseCode;
float units, grade;
nameType facultyName;
};
typedef struct courseTag arrCourses[MAX_C];
struct studentTag
{
nameType name;
arrCourses course;
int numCourse;
float CGPA;
struct studentTag *pLink;
};
typedef struct studentTag *ptrStudent; /*this alias can be used to avoid confusion in using an asterisk*/
/*you can not use the same typedef call like nameType in studentTag, because you will be calling the alias that hasn't been declared yet*/
/*This function allows to insert node in alphabetical order*/
void insert(ptrStudent *pFirst){/*Alphabtical insertion*/
char tmp;
ptrStudent pNew,pRun,pLast;
pNew=malloc(sizeof(struct studentTag));
printf("Enter first name: ");
fgets(pNew->name.first,sizeof(string25),stdin);
printf("Enter miidle intial: ");
scanf("%c%c",&pNew->name.mid,&tmp);
printf("Enter last name: ");
fgets(pNew->name.last,sizeof(string25),stdin);
pNew->pLink=NULL;
if(*pFirst==NULL)
*pFirst=pNew;
else
if(strcmp((*pFirst)->name.last,pNew->name.last)>0)
{
pNew->pLink=*pFirst;
*pFirst=pNew;
}
else {
pRun=*pFirst;
while(pRun!=NULL&&strcmp(pRun->name.last,pNew->name.last)<0)
{
pLast=pRun;
pRun=pRun->pLink;
}
if(pRun)
pNew->pLink=pRun;
pLast->pLink=pNew;
}
}
Sunday, November 28, 2010
Wednesday, November 10, 2010
Team trouble
Currently, we are suppose to be working on are term paper and presentation of it.
Somehow it seems that it can't be done since we have not even researched and do other important task for it. Unfortunately my schedule conflicts and their schedules are different from mine.
We need to be organized. I need a good grade in the report and presentation. I hope this won't end bad. My studies are important. My subjects are conflicting with me. I hope I get it together and so can the others
Somehow it seems that it can't be done since we have not even researched and do other important task for it. Unfortunately my schedule conflicts and their schedules are different from mine.
We need to be organized. I need a good grade in the report and presentation. I hope this won't end bad. My studies are important. My subjects are conflicting with me. I hope I get it together and so can the others
Friday, November 5, 2010
I realized form C programming
I have been studying c programming for the past months and I am in a good pace but I wish I can learn faster. It takes a month for me to learn the c language. It takes even longer to improve it. My skills improve with practice practice practice. I have no plans on stopping because I like doing it. I have passion for programming which is why I pursue learning it. I plan to learn other languages now.#
I am interested in object oriented programming. I saw this site http://www.programmersheaven.com/2/VB-NET-School and I learned Vb at a nice pace. I still want to learn more though. I plan to learn windows forms. I also want to learn c++
The other platform is java. I learned some basic java (luckily it is similar to c). Net beans helped a lot. I plan to learn more about it some other time.
I realized that it is effective to learn one platform at a time to save me from more confusion. I have confirmed that having passion on subjects you're passionate about can really makes effective learning.
I wish what I learn can help me in the future.
I am interested in object oriented programming. I saw this site http://www.programmersheaven.com/2/VB-NET-School and I learned Vb at a nice pace. I still want to learn more though. I plan to learn windows forms. I also want to learn c++
The other platform is java. I learned some basic java (luckily it is similar to c). Net beans helped a lot. I plan to learn more about it some other time.
I realized that it is effective to learn one platform at a time to save me from more confusion. I have confirmed that having passion on subjects you're passionate about can really makes effective learning.
I wish what I learn can help me in the future.
Wednesday, August 25, 2010
c program that displays the largest & smallest digit
================================
================================
int large(int n){
if(n==0)
return 0;
else{
if(n%10>large(n/10))
return n%10;
else
return large(n/10);
}
}
int main(){
int n,ans;
printf("Enter a value: ");
scanf("%d",&n);
ans=large(n);
printf("ans: %d",ans);
getch();
}
=====================================
=====================================
int small(int n){
if(n/10==0)
return n;
else{
if(n%10
return n%10;
else
return small(n/10);
}
}
int main(){
int n,ans;
printf("Enter a value: ");
scanf("%d",&n);
ans=small(n);
printf("ans: %d",ans);
getch();
}
================================
Displaying Largest digit from the user's input
================================
int large(int n){
if(n==0)
return 0;
else{
if(n%10>large(n/10))
return n%10;
else
return large(n/10);
}
}
int main(){
int n,ans;
printf("Enter a value: ");
scanf("%d",&n);
ans=large(n);
printf("ans: %d",ans);
getch();
}
=====================================
Displaying the smallest digit from the user's input
=====================================
int small(int n){
if(n/10==0)
return n;
else{
if(n%10
return n%10;
else
return small(n/10);
}
}
int main(){
int n,ans;
printf("Enter a value: ");
scanf("%d",&n);
ans=small(n);
printf("ans: %d",ans);
getch();
}
================================
Friday, July 23, 2010
C program that adds the digits of whole numbers
------------------------------------
#include
int main() {
int in,temp,sum=0;
printf("Enter a value: ");scanf("%d",&in);
while(in!=0){
temp=in%10;
sum+=temp;
in/=10;
}
printf("%d\n",sum);
getch();
}
------------------------------------
input <123>
the output would be<6>
#include
int main() {
int in,temp,sum=0;
printf("Enter a value: ");scanf("%d",&in);
while(in!=0){
temp=in%10;
sum+=temp;
in/=10;
}
printf("%d\n",sum);
getch();
}
------------------------------------
input <123>
the output would be<6>
Monday, July 19, 2010
Program that adds 2 sets of time info
This program adds two sets of time information in days,hours and minutes
-----------------------------------------------------------
#include
void TimeAdd(int nday,int nhrs,int nmin,int aday,int ahrs,int amin){
int carryh=0,carryd=0;
nmin+=amin;
if (nmin>=60){
carryh++;
nmin-=60;
}
nhrs+=+ahrs+carryh;
if (nhrs>=24){
carryd++;
nhrs-=24;
}
nday+=aday+carryd;
printf("Total: %d days, %d hours & %d miniutes",nday,nhrs,nmin);
}
int main(){
int nday,nhrs,nmin,aday,ahrs,amin;
printf("Type first set of time information in days,hours and miniutes ");
scanf("%d%d%d",&nday,&nhrs,&nmin);
printf("Type second set of time information in days,hours and miniutes ");
scanf("%d%d%d",&aday,&ahrs,&amin);
TimeAdd(nday,nhrs,nmin,aday,ahrs,amin);
}
------------------------------------------------------------------------
It works you can copy it to notepad & compile it your self
Friday, June 18, 2010
3d is over rated
there have been of reports of new devices with 3d support personally I won't get them yet since they would cost too much. The would also require you to buy more stuff with 3d support and replace your other devices just to see in 3D.
The movie industry offers more 3d movies just too charge extra and some movies are not good in 3d by the way.
3d entertainment is a wonderful concept but we can't have it all the time. It seems to early to have 3D home appliances so wait till you're ready.
The movie industry offers more 3d movies just too charge extra and some movies are not good in 3d by the way.
3d entertainment is a wonderful concept but we can't have it all the time. It seems to early to have 3D home appliances so wait till you're ready.
There is always a better model next year.
Thursday, February 11, 2010
Message for people who want free stuff
Now I can use that the english requirment is over, I will use this Blog as I wish.
Here is a list of portable free app
Here is a list of portable free app
- Portable Sumatra PDF
- slample pdf {http://dl.maximumpc.com/Archives/MPC1309-web.pdf}
- Do you know www.4shared.com
- or http://aimini.net/
- www.addictinggames.com/ for free flash games
- for free software http://sourceforge.net/
- Test Linux live cds information in http://lifehacker.com/5157811/five-best-live-cds
- Get apps from http://www.filehippo.com/
Subscribe to:
Posts (Atom)