Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C Windows
hello frndz , i got a problem in my code whenever i excute my code it dont show the obtained marks result whats the problem in it .. here is the code
 
#include<stdio.h>
#include<conio.h>

void main ()
 
{
 

float physics,obt,a,b,d,e,f,g,c,maths,computer,english,urdu,pakstudies;
float total,avg,percentage;
clrscr();
printf("	\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
printf("	\nkindly enter your total marks and obtained marks of each subject");
printf("	\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
printf("	\nEnter total marks of physics:");
scanf("%f",&physics);
printf("	\nEnter obtained marks in physics:");
scanf("\n\t %f",&a);
c=(a/physics)*100;
printf("%.3f",c);
if(c<40)
{printf("\n u R fail in physics:(");
getch();
clrscr();
}
else if(c>=40)
{
printf("\n u R pass in physics:)");
getch();
clrscr();
}
printf("	\nEnter total marks of maths:");
scanf("%f",&maths);
printf("	\nEnter obtained marks of maths:");
scanf("%f",&b);
c=(b/maths)*100;
printf("\n\t %.3f",c);
if(c<40)
{
printf("\nu R fail in maths:(");
getch();
clrscr();
}
else if(c>=40)
{
printf("\n u R pass in maths:)");
getch();
clrscr();
}
printf("	\nEnter total marks of computer:");
scanf("%f",&computer);
printf("	\nEnter obtained marks of computer:");
scanf("\n\t %f",&d);
 
c=(d/computer)*100;
printf("\n\t %.3f",c);
if(c<40)
{
printf("\n u R fail in computer:( ");
getch();
clrscr();
}
else if(c>=40)
{
printf("\n u R pass in computer:)");
getch();
clrscr();
}
 

printf("	\nEnter total marks of english:");
scanf("%f",&english);
printf("	\nEnter obtained marks of english:");
scanf("%f",&e);
c=(e/english)*100;
printf("\n\t %.3f",c);
if(c<40)
{
printf("\nu R fail in english:( ");
getch();
clrscr();
}
else if(c>=40)
{
printf("\n u R pass in english:) ");
getch();
clrscr();
}
printf("	\nEnter the marks of urdu:");
scanf("%f",&urdu);
printf("	\nEnter obtained marks of urdu:");
scanf("%f",&f);
c=(f/urdu)*100;
printf("\n\t %.3f",c);
if(c<40)
{
printf("\n u R fail in urdu:( ");
getch();
clrscr();
}
else if(c>=40)
{
printf("u R pass in urdu:) ");
getch();
clrscr();
}
 
printf("	\nenter the marks of pakstudies:");
scanf("%f",&pakstudies);
printf("	\nEnter obtained marks of pakstudies:");
scanf("%f",&g);
c=(g/pakstudies)*100;
printf("\n\t %.3f",c);
if(c<40)
{
printf("	\nu R fail in pakstudies:( ");
getch();
clrscr();
}
else if(c>=40)
{
printf("	\nu R pass in pakstudies:) ");
getch();
clrscr();
}
total=physics+maths+computer+english+urdu+pakstudies;
obt=a+b+d+e+f+g;
avg=obt/6;
 

printf("Average of marks is : %.3f",avg);
percentage=(obt*100)/total;
printf("	\nPercentage of marks is : %.2f",percentage);
if(percentage>=90)
{
printf("	\n::::::::::::::::::::::::::::::::::::::::");
printf("	\n\tyour grade is:A");
printf("	\n\tcongratulations:) you scored A grade in your exams");
printf("	\n=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-==-=");
}
else if(percentage>=80)
{printf("	\n---------------------------------------");
printf("	\n\tYOur grade is:B");
printf("	\n\tYou have passsed the exams");
printf("	\n---------------------------------------");
}
else if(percentage>=70)
{printf("	\n---------------------------------------------------------");
printf("	\n\tyour grade is:C");
printf("	\n\tYou have passed the exams");
printf("	\n--------------------------------------------------------");
} else if(percentage>=60)
{
printf("	\n-----------------------------------------------------------");
printf("	\n\tYour grade is:D");
printf("	\n\tYou have passed the exams");
printf("	\n------------------------------------------------------------");
}
else if(percentage<60)
{
printf("	\n----------------------------------------------------------------------------------------");
printf("	\n\tYour grade is:F");
printf("	\n\tI Am sorry but you are fail");
printf("	\n----------------------------------------------------------------------------------------");
}
 

printf("	\n******************************");
printf("\ntotal MArks \t OBtained marks");
printf("\n %.1f",physics,"\t %.1f",a);
printf("\n %.1f",maths,"\t %.1f", b);
printf("\n %.1f",computer,"\t %.1f",d);
printf("\n %.1f",english,"\t %.1f",e);
printf("\n %.1f",urdu,"\t %.1f",f);
printf("\n %.1f",pakstudies,g);
printf("	\n**************************");
getch();
}
Posted 22-Nov-12 3:23am
jahanxb327
Edited 22-Nov-12 3:36am
v2
Comments
Abhishek Pant at 22-Nov-12 9:45am
   
there is no such thing about hello!world problem in program :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The format of your printf is wrong:
 
printf("\n %.1f",physics,"\t %.1f",a);
 
Needs to be
 
printf("\n %.1f\t %.1f",physics, a);
 
You only have one format string and then a list of the vriables you are substituting in .
  Permalink  
Comments
jahanxb at 22-Nov-12 10:09am
   
thanks thanks thank u very much @chris Reynolds codeproject.com i love you
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Some suggestions:
  • Use meaningful variable names; a,b,c,d etc are useless and easy to misuse.
  • Use proper English (or even Urdu) in your printed messages. Cryptic 'txtspk' like "u r" makes things more difficult to understand.
  • Indent your code properly so you can easily see the boundaries of each part of the code.
  • Use functions for repetitive tasks such as displaying a message and returning a value.
  • Learn to use the debugger to step through the code and check that it is doing the right things at the right time.
  Permalink  
Comments
jahanxb at 22-Nov-12 10:12am
   
thanks Richar i will right on keep that in mind while coding :D :)
Sergey Alexandrovich Kryukov at 13-Dec-12 13:53pm
   
Useful tips, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 563
1 George Jonsson 258
2 OriginalGriff 250
3 CPallini 210
4 PIEBALDconsult 145
0 OriginalGriff 5,865
1 Sergey Alexandrovich Kryukov 5,316
2 CPallini 4,760
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 22 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100