Tuesday, 12 December 2017

Learn C language Part 5 goto unconditional jump stattements with marksheet program

#include<stdio.h>
#include<conio.h>

main()
{

int eng,math,phy,urdu,islamiat;
float percentage;
l1:
printf("Enter the marks obtained in English: ");
scanf("%d",&eng);

if(eng<0)
{
printf("\nInvalid input !obtained Marks cannot be negative\n\n");
goto l1;
}


l2:
printf("\nEnter the marks obtained in Mathematics: ");
scanf("%d",&math);


if(math<0)
{
printf("\nInvalid input !obtained Marks cannot be negative\n\n");
goto l2;
}



l3:
printf("\nEnter the marks obtained in Physics: ");
scanf("%d",&phy);
if(phy<0)
{
printf("\nInvalid input !obtained Marks cannot be negative\n\n");
goto l3;
}



l4:

printf("\nEnter the marks obtained in Urdu: ");
scanf("%d",&urdu);

if(urdu<0)
{
printf("\nInvalid input !obtained Marks cannot be negative\n\n");
goto l4;
}




l5:
printf("\nEnter the marks obtained in Islamiat: ");
scanf("%d",&islamiat);
if(islamiat<0)
{
printf("\nInvalid input !obtained Marks cannot be negative\n\n");
goto l5;
}





percentage= ((eng+math+phy+urdu+islamiat)*100/500);

printf("Percentage: %.2f",percentage);

printf("\n\n\n Grade:");
if(percentage>=80)
{
printf("A+");

}
else if(percentage>=70)
{
printf("A");
}
else if(percentage>=60)
{
printf("B");
}
else if(percentage>=50)
{
printf("C");
}
else
{
printf("F");

}





}

No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...