Turn on thread page Beta
    • Thread Starter
    Offline

    0
    ReputationRep:
    hi,
    I am just an infant in the world of programming.My teacher gave me the assignment abt my first C program as:"write a C program whose output should be mathematical table of your Roll No."

    So this is wt i wrote.


    #include <stdio.h>
    int x=61;
    {
    printf("x*61=%d",61);/*in this way i wrote the table till 10*/
    return 0;
    }

    in C3,the compiler says,Declaration ended in correctly.
    I just can't sort this problem out.
    1.So far as i have gone,i have learned that { is a part of every program.How could i terminate it?
    2.How could i introduce an integer so that it might not effect my program?
    THX
    Offline

    1
    ReputationRep:
    Can you just tell me in normal English terms what are your required inputs and expected outputs?
    Offline

    0
    ReputationRep:
    Matlab?
    • Thread Starter
    Offline

    0
    ReputationRep:
    I want out put:

    61*1=61
    62*2=122
    63*3=183
    64*4=244
    64*5=305

    For this i am putting this input in my C program:

    #include <stdio.h>
    int x=61;
    {
    printf("61*1=%d",61);
    printf(''61*2=%d",122);
    printf(''61*3=%d",183);
    printf(''61*4=%d",244);
    printf(''61*5=%d",305);
    return 0;
    }

    (Original post by neodymium)
    Can you just tell me in normal English terms what are your required inputs and expected outputs?
    whatelse did i wrote but normal english?
    (Original post by Yusef Badi)
    Matlab?
    matlab is clear now.
    Offline

    1
    ReputationRep:
    Your program should be this:

    #include <stdio.h>
    #include <conio.h>

    void main {

    int x=61;

    printf("61*1=%d",61);
    printf("61*2=%d",122);
    printf("61*3=%d",183);
    printf("61*4=%d",244);
    printf("61*5=%d",305);

    getch();
    return 0;
    }
    • Thread Starter
    Offline

    0
    ReputationRep:
    But i haven't so farlearned abt these 2 thingskeep in mind,i am just a beginner)
    1.#include <conio.h>
    2.void main {
    3.getch();

    i want a program without these 3 things.Is this possible?
    Offline

    9
    ReputationRep:
    there is a way, yes.
    • Thread Starter
    Offline

    0
    ReputationRep:
    (Original post by MrGreedy)
    there is a way, yes.
    when will u break that way to me?
    I have to submit assignment tomarrow,that's why i am in such haste!
    Offline

    1
    ReputationRep:
    (Original post by Xatima)
    But i haven't so farlearned abt these 2 thingskeep in mind,i am just a beginner)
    1.#include <conio.h>
    2.void main {
    3.getch();

    i want a program without these 3 things.Is this possible?
    All C programs have a void main() section. That forms the main part of the program. You can't remove it.

    You need conio.h to use the function getch(). You can get rid of these two, but then you won't be able to see the output of your program as it would exit as soon as printf is done.
    • Thread Starter
    Offline

    0
    ReputationRep:
    oh thx a lot to u.Its done now.
    i have done this:

    #include <stdio.h>
    int main (void)
    {
    int x=61;
    printf("61*1=%d",61);
    return 0;
    }

    and it gave me out put:
    61*1=61
    • Thread Starter
    Offline

    0
    ReputationRep:
    just one more thing;i want to take a print of my program output from C,how to do it?if i use print command in C program,it gives me"bad image of FAT detected'.
 
 
 
Poll
Brexit: Given the chance now, would you vote leave or remain?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.