lundi 3 mai 2021

Program is not printing completely

I'm trying programming 1st time and not getting the output of this program.Though it looks simple but the code doesn't prints after taking the input like name, roll, marks obtained by student. I have attached the screenshot of compiler. Thank you!

#include<stdio.h>

int main()
{

    int roll,phy,che,ca,total;
    float percentage;
    char name[20];
    
    printf("enter the name of student: ");  //studentname
    scanf("%s",&name);
    printf("enter the roll number: ");      //roll number
    scanf("%d",&roll);
    printf("enter the marks obtained in phy,che,ca: "); //marks obtained/subject
    scanf("%d%d%d ",&phy,&che,&ca);
    
    //doesnt works from here.
    
    total= (phy+che+ca);        //calculating total marks 
    printf("the total marks obtained is %d\n",total); 
    percentage =total/3.0;          //calculating percentage student got.
    printf("the total percentage obtained is %d\n",percentage);
    
    if(percentage>=80)
        printf("first division\n");             //first division
    else if(percentage>=60 && percentage<=80)
        printf("second division\n");            //second division
    else if(percentage>=60)
        printf("third divison\n");              //third division
    else if(percentage>=10)
        printf("you failed!\n");                //failed
    else
        printf("invalid input\n");              //invalid input
    
    return 0;
    
}

screenshot of the compiler

Aucun commentaire:

Enregistrer un commentaire