Tuesday, September 21, 2010

Programming in C

Hello Learners

Sorry for being so late at creating this class blog. If you have any problems with code or anything here is the place to talk about it during the week. All the best.

Steve

73 comments:

  1. Hi sir,i need another compiler, please

    ReplyDelete
  2. Please Help.
    What's wrong with my program?
    I'll be back Friday.

    #include
    main(){
    int a,b,c ;// finding the sum of three numbers
    int SUM=a+b+c;
    int TOTAL;

    printf("Welcome user:-)");
    printf("\nplease enter 1st digit>>");
    scanf("%n",a);
    printf("\nplease enter 2nd digit>>");
    scanf("%n",b);
    printf("\nplease enter 3rd digit>>");
    scanf("%n",c);
    SUM=("%n+%n+%n",a,b,c);
    printf("\nYour Answer Is %n",SUM);

    ReplyDelete
  3. 1 of the problems is u forgot to end it with }

    ReplyDelete
  4. No sir, i didn't copy it for the message, it was in the program:-)
    i used this online compiler
    http://cmpe150-1.cmpe.boun.edu.tr/phpccompiler/login.php

    #include

    main(){

    int a,b,c;// finding the sum of three numbers

    int SUM=a+b+c;

    int TOTAL;

    printf("Welcome user:-)");

    printf("\nplease enter 1st digit>>");

    scanf("%n",a);

    printf("\nplease enter 2nd digit>>");

    scanf("%n",b);

    printf("\nplease enter 3rd digit>>");

    scanf("%n",c);

    SUM=("%n+%n+%n",a,b,c);

    printf("\nYour Answer Is %n",SUM);

    getchar();

    }

    ReplyDelete
  5. U didn't put in stdio.h
    after #include.
    Also try using dev c++ 4.9.9.2

    ReplyDelete
  6. Natalie try running your program from the command prompt. If you don't know how i will guide u through.I tried this in my compiler and didn't work but got the result in the command prompt.

    #include stdio.h

    main(){
    int a,b;
    printf("enter first number:");
    scanf("%d",&a);
    printf("enter second number:");
    scanf("%d", &b);
    printf("%d + %d = %d\n",a,b,a+b);
    getchar();
    }

    Result:50+50=100

    ReplyDelete
  7. Sir i am using dev-c++ and its working but not what i did in class.. example
    #include
    int main ()
    {
    using namespace std;
    cout << "Hey stephan.";
    cout << endl;
    cout << "Dont slap shannon!" <<endl;
    system ("pause");
    return 0;
    }

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. is what am doing wrong

    ReplyDelete
  10. hey stephan tying to run this in turbo c+ as well but jus cant seem to get it to work will try it from the command prompt.

    ReplyDelete
  11. This comment has been removed by a blog administrator.

    ReplyDelete
  12. stdio.h put iostream

    ReplyDelete
  13. miracle c is the best, dev++ dosent like me.

    ReplyDelete
  14. for the complier to output

    ReplyDelete
  15. can someone help me in finding a link to a compiler. hav try dev, tiny c and miracle c--dosnt work. i would prefer any one that works

    ReplyDelete
  16. sir my compilers not working need gudiance

    ReplyDelete
  17. Randy send me ur email will send u the compiler from school. Curious to know whats happening with dev c?

    ReplyDelete
  18. hi aneesa my email is randybee@hotmail.com
    much thanks

    ReplyDelete
  19. a complier please!!!!

    ReplyDelete
  20. randy did u get the compiler or u want me to email you the one we use in school?

    ReplyDelete
  21. aneesa can you send me dat one from school.how get it . i have been to get free version but keep hitting a wall

    ReplyDelete
  22. Hey, i need help trying to make a program to solve quadratic equations, how would i enter the square reet part?

    // // This program finds the x cordinates of a quadratic equation
    #include
    main(){
    float a,b,c,TOTAL1,TOTAL2,x1,x2;
    printf("WELCOME TO QUADRATIC CALCULATOR:-)");
    printf("\nPlease enter the value of a\n");
    scanf("%f",&a);
    printf("\nPlease enter the value of b\n");
    scanf("%f",&b);
    printf("\nPlease enter the value of c\n");
    scanf("%f",&c);
    TOTAL1= b*b-4*a*c;
    printf("\nTOTAL1 IS %f\n",TOTAL1);
    TOTAL2= TOTAL1*.5;
    x1=(-b+TOTAL1)/2*a;
    x2=(-b-TOTAL2)/2*a;
    printf("\nYour answer is x1=%f\n",x1);
    printf("\nYour answer is x2=%f\n",x2);
    }

    ReplyDelete
  23. x = ( -b +/- sqrt(b - 4 a c) ) / (2 a).........i think this is how you enter it ......try it and see if it works.

    ReplyDelete
  24. Randy neither msn or yahoo allowing me to send the compiler cuz of its extension (exe.)......if u have any ideas on how to bypass this feel free to share......otherwise will bring on sunday.

    ReplyDelete
  25. Hey class, Andy bro I will send it for you but I dont know if it will work

    ReplyDelete
  26. Hi can anybody send me a complier ? Nothing I tried is working with my PC.

    ReplyDelete
  27. Natasha what compilers have you tried???

    ReplyDelete
  28. http://punuptech.com/2010/04/turbo-cc-on-3264-bit-vistawindows-7xp/

    visit this site for a step by step in: How to install and download Turbo C++ on a 64 or 32bit computer.

    Hope it works.

    ReplyDelete
  29. @natalie you can't put %n in ur 1st program its suppose to be %d

    ReplyDelete
  30. @natalie in ur second program u will need to use the maths library this is used to conduct math functions

    ReplyDelete
  31. sir could u please e-mail me the course outline i never got one.

    ReplyDelete
  32. also can someone help me get a compiler please it would be greatly appreciated

    ReplyDelete
  33. you can look on the school server you will get the software for turbo C++

    ReplyDelete
  34. Anyone needs help with their class assignment? feel free to ask.

    ReplyDelete
  35. I know it's not finished but after i type in the hours worked the programme cuts off:

    # include
    main()
    {
    double hrs,rate,reg,tax,gross,ot;
    char name[24];

    printf("enter name: \t");
    scanf("%s",&name);

    printf("hrs worked: \t");
    scanf("%4.2lf",&hrs);

    printf("rate of pay: \t");
    scanf("%4.2lf",&rate);

    if (hrs<=40){
    reg = hrs * rate;
    ot=(hrs-40)*rate*1.5; }


    getchar();

    ReplyDelete
  36. Hello All

    The mid-term examination will be next week on the 17th October. I am new to ROYTEC and there examination procedures and there are some processes that I have to go through. We will talk tomorrow in class about this. So we continue with class work in the morning - 9th October 2010

    ReplyDelete
  37. Assessment 1
    Write an algorithm and the IPO before writing a program to solve the following problem:
    The program must request the name, subject and marks of five students and display them according to the grades based on a pre-defined grade scheme.

    Assessment 2
    Write an algorithm and the IPO before writing a program to solve the following problem:
    A bank pays interest based on the amount of money deposited. If the amount is less than $5,000, the interest is 4% per annum. If the amount is $5,000 or more but less than $10,000, the interest is 5% per annum. If the amount is $10,000 or more but less than $20,000, the interest is 6% per annum. If the amount is $20,000 or more, the interest is 7% per annum.
    The program must be submitted without any syntax and warning errors.

    ReplyDelete
  38. Hi Sir thanks for not emailing the blog for me Nicole Spring

    ReplyDelete
  39. // code for quadratic equations
    #include
    #include
    #include

    // function to evaluate the determinant
    double determinant(double arg_a, double arg_b, double arg_c) {
    return (arg_b * arg_b) - (4 * arg_a * arg_c);
    } // end determinant

    // function to evaluate real roots
    void realRoots(double arg_a, double arg_b, double arg_sqrt) {
    double firstRoot = (-arg_b/(2 * arg_a)) +
    (arg_sqrt/(2 * arg_a));
    double secondRoot = (-arg_b/(2 * arg_a)) -
    (arg_sqrt/(2 * arg_a));
    cout << "\nFirst Real Root: \t" << firstRoot << "\n";
    cout << "Second Real Root: \t" << secondRoot << "\n";
    } // end realRoots

    void output1(double first, double second) {
    cout << "\nFirst Imaginary Root: \t" << first << " + " << second << "i" << "\n";
    cout << "\nSecond Imaginary Root: \t" << first << " - " << second << "i" << "\n";
    } // end output1()

    void output2(double first, double second) {
    second = -(second); // change the sign of the second term, for correct output
    cout << "\nFirst Imaginary Root: \t" << first << " - " << second << "i" << "\n";
    cout << "\nSecond Imaginary Root: \t" << first << " + " << second << "i" << "\n";
    } // end output2()

    // evaluate imaginary roots
    void imaginaryRoots(double arg_a, double arg_b, double arg_imag_sqrt) {
    double two_a = 2 * arg_a;
    double first_term = (-arg_b)/two_a;
    double second_term = (arg_imag_sqrt)/two_a;

    if(second_term >= 0) {
    //cout << "\nsecond_term is greater than or eaqual to 0: " << second_term << "\n";
    output1(first_term, second_term);
    } // end if
    else {
    //cout << "\nsecond_term is less than or eaqual to 0: " << second_term << "\n";
    output2(first_term, second_term);
    } // end else

    } // end imaginaryRoots

    // main function
    int main()
    {
    cout << "\n***********************************************************************\n";
    cout << "* Find the roots of a quadratic equation in standard form. *";
    cout << "\n***********************************************************************\n";

    // declare variables a, b, and c
    double a, b, c;
    char n;

    do {
    cout << "\nEnter the value of 'a': ";
    cin >> a;
    cout << "Enter the value of 'b': ";
    cin >> b;
    cout << "Enter the value of 'c': ";
    cin >> c;

    double det = determinant(a, b, c);

    if (det >= 0) {
    realRoots(a, b, sqrt(det)); // roots are real
    } // end if
    else {
    imaginaryRoots(a, b, sqrt(-det)); // roots are imaginary
    } // end else

    cout << "\nWould you like to solve another?";
    cout << "\nEnter 'y' for 'Yes' -- 'n' for 'No': ";
    cin >> n;
    cout << "\n";

    } while (n == 'y' || n == 'Y'); // end do-while loop

    return 0;
    }

    ReplyDelete
  40. hi sir can i get my 10% now, it was a task 4 me to get through this blog :)

    ReplyDelete
  41. void main(){
    int hours ,rate,regPay,ovtPay,grosPay,netPay,tax;
    char name[16];

    printf("PLease enter employee name:\t");
    scanf("%s",&name);
    printf("\nHours worked\t");
    scanf("%d",&hours);
    printf("\nRate of Pay?\t");
    scanf("%d",&rate);

    if (hours <=40){
    regPay= hours * rate ;
    ovtPay =0;
    }
    else{
    regPay= 40* rate;
    ovtPay=(hours - 40)* rate*1.5;
    }
    grosPay = regPay + ovtPay;
    netPay= (hours*rate );
    tax= grosPay -0.08;

    printf(" \n*ALL INFORMATION ENTERED!*\n");
    printf("\nName of employee %s",name);
    printf("\nGross pay:$%d\n",grosPay);
    printf("\nTax deducted :$%d\n",tax);
    printf("\nNet Pay : $ %d\n",netPay);

    }

    ReplyDelete
  42. hey wasn't in class today what were the topics discussed and when is the 1st assignment due sir

    ReplyDelete
  43. #include
    main(){
    char name1 [30];
    int score;
    printf("Enter Name\t\n");
    scanf("%d",&name1);
    printf("Enter Mark\t\n");
    scanf("%d",&score);
    }
    Can some tell me what is wrong. when i run the program there is no option to enter the mark

    ReplyDelete
  44. sir, still awaiting your answer from last class concerning the exam

    ReplyDelete
  45. randy this is what i did

    #include
    main()
    {
    double s1,s2,s3,m1,final;
    printf("Term Test Marks\n");
    printf("\nFirst Mark: ");
    scanf("%lf",&s1);
    printf("Second Mark: ");
    scanf("%lf",&s2);
    printf("Third Mark: ");
    scanf("%lf",&s3);

    printf("\nEnd Of Term\n");
    printf("\nMark: ");
    scanf("%lf",&m1);

    final=((s1+s2+s3)/75*50)+ m1/100*50;
    printf("Final Score: %.0lf\n",final);

    if(final>=50){printf("Student Pass\n");}

    else{(printf("Fail\n"));
    }
    }

    ReplyDelete
  46. anessa. but why u using the sum of three marks,the ques ask for the marks of five different students and corres grade.But i still like the program

    ReplyDelete
  47. Lol sry randy i gave u d wrong program. still working on that one.

    ReplyDelete
  48. Must Say dev C is the worst nof of my programes work with it

    ReplyDelete
  49. i gave up on thst dev c long time. use the turbo c copy u email to me. it working on my pc-- using old school OS though XP not the fancy one you got.

    ReplyDelete
  50. any word on mid term . is it confirm for this sunday 17. or not? Sir please let us know!!

    ReplyDelete
  51. having trouble with my if/else statements, and have no idea what i'm doing wrong

    ReplyDelete
  52. Please find below the 3rd assignment which will be due on 7th October 2010.

    Write a program to solve the following problem:
    The program must request the name, subject and five test scores of five (5) students for their course work in History for a school term from a file, “historyinput.txt”. Each test score is marked out of 10 marks. Compute the average mark and send the result to another file, “historyoutput.txt”, based on the following grade scheme shown below.

    Mark Grade
    90-100 A
    80-89 B
    70-79 C
    60-69 D
    50-59 E
    0-49 F

    ReplyDelete
  53. Hello All

    Unfortunately I have to leave the country on 14th November and miss the class carded for that day. This means that we need to have a make-up class. The make-up class will be on Monday 8th November 2010 from 5 pm - 8 pm.

    ReplyDelete
  54. I have another class on 8 november at said time

    ReplyDelete
  55. sorry sir but i can't attend the makeup class on the 8th.i'm from san fernando and i will have trouble for transport that late at night

    ReplyDelete
  56. Please come to class and we will see how this can work out for everyone.

    ReplyDelete
  57. Just spoke to Mr. Warner and we do not have class today the room is not available. Therefore he would like to have class tomorrow (Tuesday 8th November,10 @5pm-8pm). Anyone with any objections please post.

    ReplyDelete
  58. I have a class at that time so i would not be able to make it

    ReplyDelete
  59. does anyone have sir's email address?? plz post

    ReplyDelete
  60. this is sir email:stewenchic@yahoo.com

    ReplyDelete
  61. http://www.cprogramming.com/how_to_learn_to_program.html

    ReplyDelete
  62. have sir given any pointers on what might come for finally.has anyone given in all their assigments, i still working on the last one.

    ReplyDelete
  63. only chapters 1-5 coming,and once u get all his assignments especially the last one,you will be fine. i tiring to get the string compare thing on page 108 so i could do his assignment. If anybody want to study together i'm game!
    nattynovember@gmail.com

    ReplyDelete
  64. thanks very much natalie. still trying to finish the last assig. good luck

    ReplyDelete
  65. HINTS FOR TEST:
    section1:
    10 multiple choice (10 marks)
    section2:
    writing an IPO, algorithm, and program similar to assignment 2.(30 marks)
    you are given an algorithm and you have to state the output
    you are given a program and you have to state the output
    definitions:sentinel,syntax,n++,++n, n--,--n,n*=m

    ReplyDelete
  66. thanks nikk and natalie for the hints. hope we all past

    ReplyDelete
  67. Would anyone like to form a group just for an hour or two for revision? during the week,i know you have other exams buh please...

    ReplyDelete
  68. hey natalie if you lik we could study online add me to your contact lists. randybee@hotmail.com. let me through this blog when you have done so. i will be studing some programming from bout 1pm

    ReplyDelete
  69. anyone knows if sir is back yet, and did he give out our marks yet..

    ReplyDelete