Thread: Help me pleasee T^T

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    2

    Help me pleasee T^T

    This is one of my home work .But I have a problem is I don't know why %c can't with while,for or do while loops please help me

    Code:
    #include<stdio.h>
    #include<conio.h>
    
    
    
    main(){
           int ids,no,x ;
           char nam ;
           float gpa ;
    
           
           printf("------------------------------------------------\n");
           printf("             Program Study Result\n ");
           printf("------------------------------------------------\n");
           printf("Enter number of student : ");
                         scanf("%d",&no);
           printf("\n------------------------------------------------");
          
          x = 1;
           while (x<=no) {
                 
                  
           printf("\nStudent No.%d",x ); 
           printf("\nEnter student id : ");
                         scanf("%d",&ids);                  
           printf("Enter student name : ");
                      gets(nam); 
           printf("\nEnter student GPA : ");
                         scanf("%f",&gpa); 
               if  (gpa>=2.00){
                       printf("\nStudy result is : PASS "); }
               else 
                       printf("\nStudy result is : NOT PASS "); 
            x++;
                         }        
                       
           printf("\n------------------------------------------------\n");
           
           getch();
    
    }
    and please help me write this program by for loops

    _____X
    ___XXX
    XXXXXX
    ___XXX
    _____X

    Thank you very much for help...


    I,m thai, I know english a little bit .

    I'm sorry, if some word I type you don't know.
    Last edited by winterday; 07-26-2010 at 08:59 AM.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    74
    you want to turn the while into a for loop?

    btw, use fgets() instead of gets and declare the main function as int main(void).

  3. #3
    Registered User
    Join Date
    Jun 2010
    Posts
    27
    The variable "nam" must be a string array when you call gets() to initialize it.BTW, the variable "no" hasn't been initialized.

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Quote Originally Posted by Steve Cao View Post
    BTW, the variable "no" hasn't been initialized.
    Yes it has:
    Code:
    printf("Enter number of student : ");
    scanf("%d",&no);
    ... better indentation of the original post's code is recommended.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    Registered User
    Join Date
    Jul 2010
    Posts
    2
    I can run this question by...

    change int x; to float x;

    and

    printf("\nStudent No.%d",x );

    to

    printf("\nStudent No.%0.0f",x );



    thanks everyone for Advice.

Popular pages Recent additions subscribe to a feed

Tags for this Thread