cannot convert char to char & illegal use of floating point
Aug 13, 2014 at 2:13am UTC
Excuse me for asking such a simple silly question but i'm new to programming and in need of some serious help.
Below is a simple program that the user enters the number of subjects taken --> the grade (A,B,C etc.) --> and the program calculates and prints the students transcript including all the cgpa.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char string[10];
char grade[10];
float out[10];
int num;
float cgpa=0.0;
for (int x=0;x<num;x++)
{
printf("\nEnter the number of subjects? \n " );
scanf("%d" ,&num);
printf("\nEnter Student Name: \n" );
scanf("%s" ,&string[x]);
printf("\nEnter Student Grade: \n" );
scanf("%s" ,&grade[x]);
if (grade[x]>="A" || grade[x]>="a" )
out[x]==4.0;
else if (grade[x]>="B" || grade[x]>="b" )
out[x]==3.0;
else if (grade[x]>="C" || grade[x]>="c" )
out[x]==2.0;
else if (grade[x]>="D" || grade[x]>="d" )
out[x]==1.3;
else if (grade[x]>="F" || grade[x]>="f" )
out[x]==0.1;
else
printf("You've entered a wrong grade" );
}
cgpa+=out;
cgpa=cgpa/num;
printf("%s\n" , string);
printf("%s\n" , grade);
printf("%f\n" , cgpa);
getch();
}
My main problem is that i keep on getting the two following errors:
- Cannot convert char to char*
- illegal use of floating point
The errors i'm getting are on the following lines:
1 2 3 4 5 6 7 8 9 10 11 12
if (grade[x]>="A" || grade[x]>="a" )
out[x]==4.0;
else if (grade[x]>="B" || grade[x]>="b" )
out[x]==3.0;
else if (grade[x]>="C" || grade[x]>="c" )
out[x]==2.0;
else if (grade[x]>="D" || grade[x]>="d" )
out[x]==1.3;
else if (grade[x]>="F" || grade[x]>="f" )
out[x]==0.1;
the illegal use of floating point error is on this line:
Thanks in advanced.
Aug 13, 2014 at 7:41am UTC
try changing "A" to 'A'
Topic archived. No new replies allowed.