Thread: plz help me out guyz!!!!!!!!

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    63

    plz help me out guyz!!!!!!!!

    hi
    could u plz help me out with this array program that i have written ....there is NO error in this program while compiling...but it's not running well .the output is not coming our right as it should.i don't know why........i have checked it 100 times and i still can't figure out why is it not running well.........?
    this program is about.....A TEST CONSISTING OF 8 MULTIPLE CHOICE ITEMS(QUESTIONS) IS ADMINISTERED TO A BATCH OF 3 STUDENTS.
    so i have done like this:-

    #include<stdio.h>
    #include<conio.h>
    #define STUDENTS 3
    #define ITEMS 8
    void main()
    {
    char key[ITEMS+1],response[ITEMS+1];
    int i,student,count,n,correct[ITEMS+1];
    /* reading of correct answers into an array*/
    printf("input key to the items");
    for(i=0;i<ITEMS;i++)
    scanf("%c",&key[i]);
    /*evaluation begins*/
    for(student=1;student<=STUDENTS;student++)
    {
    /*reading student responses and counting correct ones*/
    count=0;
    printf("input response of student:%d",student);
    for(i=0;i<ITEMS;i++)
    scanf("%c",&response[i]);
    for(i=0;i<ITEMS;i++)
    correct[i]=0;
    for(i=0;i<ITEMS;i++)
    if(response[i]==key[i])
    {
    count=count+1;
    correct[i]=1;
    }
    /*printing of results*/
    printf("student:%d",student)
    printf("score is %d out of %d\n",count,ITEMS);
    printf("response to the following items are wrong\n");
    n=0;
    for(i=0;i<ITEMS;i++)
    if(correct[i]==0)
    {
    printf("%d",i+1);
    n=n+1;
    }
    if(n==0)
    {
    printf("nil\n");
    }
    getch();
    }

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Code tags

    void main() - Bad

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    21
    /*printing of results*/
    printf("student:%d",student)
    you are missing a semicolon here
    and a } should be added to the end of your above statements...

    Use code tags kind of hard to see your codes

  4. #4
    Registered User
    Join Date
    Aug 2004
    Posts
    21
    for(i=0;i<ITEMS;i++)
    if(correct[i]==0)
    {
    printf("%d",i+1);
    n=n+1;
    }
    It also seems you are missing a pair of {} here to run the 'for' loop.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Closed - for repeated failure to use code tags, void main, crypto-speak and run-on sentences.
    Not to mention 3 begging posts in the last 24 hours

    Replies here
    http://cboard.cprogramming.com/showthread.php?t=57962
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can any1 plz make this assignment
    By jean in forum C Programming
    Replies: 17
    Last Post: 05-13-2009, 09:19 PM
  2. [Request] Need Help Plz
    By TylerD in forum Tech Board
    Replies: 4
    Last Post: 01-03-2009, 09:54 AM
  3. plz help me with simple string comparison.
    By MegaManZZ in forum C++ Programming
    Replies: 11
    Last Post: 02-18-2008, 01:11 PM
  4. Anyone plz help me
    By Rose_Flowers in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-17-2003, 12:01 PM
  5. help plz plz
    By nsssn73 in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 08:44 AM