Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

ABOUT C..........let us c the program i have written i'll explain what my q is.?

i have written this program with no errors now I WANT TO USE IF FUNCTION OR ANY THING SUCH THAT I GET THE OUTPUT "FAIL" IF THE PERSON IS FAILING THAT IS <35 MARKS IN ANY OF THESE SUBJECTS AT THE END suppose he got 15 marks in hindi and passing in other subjects i should get fail at the end

main()

{

int ,hindi,english,maths,science,social,percentage,total,average,good;

printf("enter the marks in hindi: ");

scanf("%d",&hindi);

printf("enter the marks in english: ");

scanf("%d",&english);

printf("enter the marks in maths: ");

scanf("%d",&maths);

printf("enter the marks in science: ");

scanf("%d",&science);

printf("enter the marks in social: ");

scanf("%d",&social);

total=(telugu+hindi+english+maths+science+social);

percentage=total/6;

printf("the percentage is %d\n",percentage);

if(percentage<50)

printf("average\n");

else if(percentage>70)

printf("good\n");

printf(" a prrrrrrrrroooooogggggggrrrrrrrrraaaaaaaammmmmmmm written by sanjay\n");

getch();

}

3 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    main()

    {

    int ,hindi,english,maths,science,social,perc...

    printf("enter the marks in hindi: ");

    scanf("%d",&hindi);

    printf("enter the marks in english: ");

    scanf("%d",&english);

    printf("enter the marks in maths: ");

    scanf("%d",&maths);

    printf("enter the marks in science: ");

    scanf("%d",&science);

    printf("enter the marks in social: ");

    scanf("%d",&social);

    total=(telugu+hindi+english+maths+scie...

    if(telgu>35)&& (hindi>35)&& (english>35)&& (maths>35)&& (science>35)&& socialscince>35)

    Printf(“pass”)

    Else

    Printf(“fail”)

    percentage=total/6;

    printf("the percentage is %d\n",percentage);

    if(percentage<50)

    printf("average\n");

    else if(percentage>70)

    printf("good\n");

    getch();

    }

  • 1 decade ago

    You can use the IF condition as follows.

    if (hindi < 35 || english < 35 || maths < 35 || science < 35 || social < 35)

    printf("FAIL\n");

    The above condition will become TRUE, if any one is TRUE.

    If hindi is less than 35, it will not check for the remaining, as the condition

    became true. ie the || (OR condition) traverses from left to right and stops

    if any TRUE condition encounterd. If hindi and english are greated than 35 and maths is less than 35, then the check will come till maths and then prints FAIL.

    Hope, I am not confusing you :)

  • 1 decade ago

    its better u use an array for instead of subject names and contn. like this...

    say sub[0]..for hindi and so on..

    int flag=0;

    for(i=0;i<6;i++)

    {

    if(sub(i)<35)

    {

    flag=1;

    }

    }

    if(flag=1)

    printf("fail");

    else

    printf("pass");

    is that fine.....

Still have questions? Get your answers by asking now.