Monday, January 11, 2010

About me and learning C++ in Seneca college.

O my god I just created my first blog.
If it goes like this I will become a computer geek.

3 comments:

  1. And also I registered my nick name in IRC

    ReplyDelete
  2. I wrote a small program wich summorise knolege I got from the second lecture. I will try to upload it. And the world will never be the same after this :-)

    ReplyDelete
  3. We had a quiz on C language today in a class at Seneca college. Here the quiz with answers. I will really appreciate if somebody will check the first and tenth questions, the rest compiler already checked for me.


    /* Question 1 */
    /* Main returning "0". Where the "0" is being return to and why? */

    /* I think the answer is :Operation system. The value zero depending
    on the program specs can mean anything, but usually it means no error.
    pleas correct me if I am wrong*/


    /* Question 2 */
    #include
    main() {
    int a=1;
    int b;
    b=a++ +2;
    printf("%d", b);
    b=++a+2;
    printf("%d\n", b);
    }
    /* the answer is 35 */



    /*Question 3*/
    #include
    main(){
    int a=25;
    int c=10;
    c=!!a;
    printf("%d\n", c);
    }
    /*the answer is: 1 */



    /*Question 4*/
    #include
    main(){
    int a[10]={1,4,9,0,4,6,3,2,5,3};
    int n=0;
    int i;
    for(i=0; i<10; i++) {
    n+=a[i]<5;
    }
    printf("%d\n", n);
    }
    /*the answer is: 7 */




    /*Question 5*/
    #include
    main(){
    int a[10]={1,4,9,0,4,6,3,2,5,3};
    int n;
    int i;
    for(n=0, i=0; i<10;n+=a[i++]>5);
    printf("%d\n", n);
    }

    /*the answer is: 2 */



    /* Question 6 */
    #include
    main(){
    int a[10]={1,4,9,0,4,6,3,2,5,3};
    int n;
    int i;
    for(i=0;i<10;n+= a[i++]>5);
    printf("%d\n", n);
    }
    /* the answer is: Unnown because n was not initialized */


    /* Question 7 */
    #include
    main(){
    int a[10]={1,4,9,0,4,6,3,2,5,3};
    int i;
    for(i=0;i<10; a[i]>5 && printf("%d", a[i]), i++);
    /* the answer is: Syntax Error - condition a[i]>5 is in wrong part of 'for' staitment */

    /* Question 8 */
    #include
    main(){
    int a=1;
    int b=2;
    if(a>1&&b==(a=a+1)) {
    printf("x\n");
    }
    printf("%d\n", a);

    }
    /*the answer is 1 */



    /* Question 9 */
    #include
    main(){
    int a=printf("hello\b\n");
    printf("%d", a);
    }
    /*the answer is:
    hello
    7
    printf returns a number of successfully printed characters - 7 */

    /* Question 10 */
    /*What does #include do? */
    /*I think the answer is: Copies stdio.h file into current file at the location/line it was written */
    /*Please correct me if I am wrong */

    ReplyDelete