Friday, March 28, 2014

Print passed and failed students from 10 students. If 8 students are passed then give bonus to instructor otherwise No Bonus.

#include<stdio.h>
#include<stdlib.h>
void line()
{
int i,j;
printf("\n");
for(i=1;i<=42;i++)
printf("=");
}
void header()
{
printf("\n");
printf("Built and Designed by Arslan Malik\n\n www.CworldbyAS.blogspot.com");
printf("\n");
}
int main()
{
line();
header();
line();

int passes=0,fails=0,student=1,result;


while(student<=10)
{
    printf("\nEnter '1' for passes and '2' for fails = ",result);
    scanf("%d",&result);

    {if (result==1)
    passes=passes+student;
    printf("Pass = %d",passes);

    if (result==2)
    fails=fails+student;
    printf("\n");
    printf("Passed = %d ",passes);
    printf("\nFailure = %d ", fails);
    line();}
    {if (passes>=8)
    printf("\nBonus to instructor\n----------------------\n\n\n");
    else
    printf("\nNo Bonus");
    printf("\n----------\n\n\n");}
}


return 0;
}

No comments:

Post a Comment