using g++ compiler and code is compiling and running successfully. as I know that C doesn't have separate data type for string and stores the string as an array of character I don't know why the heck this is compiling without initializing the char as array.
#include <stdio.h>
int main(){
int total_ch=0;
int total_courses=2;
float sum=0.0;
float gpa=0.0;
for(int i=0;i < total_courses; i++){
printf("%d \n",total_courses);
char course;
int marks=0;
int ch=0;
float cgpa=0.0;
printf("Enter the course name: \n");
scanf(" %s",course);
printf("Enter the credit hours of the course\n");
scanf(" %d",&ch);
printf("Enter the marks of the course\n");
scanf(" %d",&marks);
total_ch += ch;
if (marks > 85){
printf("Your Cgpa of %s is 4.00 and your grade is A\n",&course);
sum+=(ch*4.00);
}else if (marks > 79 && marks < 86 ){
printf("Your Cgpa of %s is 3.67 and your grade is A-\n",&course);
sum+=(ch*3.67);
}else if (marks > 75 && marks < 80){
printf("Your Cgpa of %s is 3.33 and your grade is B+\n",&course);
sum+=(ch*3.33);
}else if (marks > 71 && marks < 76){
printf("Your Cgpa of %s is 3.00 and your grade is B\n",&course);
sum+=(ch*3.00);
}else if (marks > 67 && marks < 72){
printf("Your Cgpa of %s is 2.67 and your grade is B-\n",&course);
sum+=(ch*2.67);
}else if (marks > 63 && marks < 68){
printf("Your Cgpa of %s is 2.50 and your grade is C+\n",&course);
sum+=(ch*2.50);
}else if (marks > 59 && marks < 64){
printf("Your Cgpa of %s is 2.00 and your grade is C\n",&course);
sum+=(ch*2.00);
}else if (marks > 56 && marks < 60){
printf("Your Cgpa of %s is 1.67 and your grade is C-\n",&course);
sum+=(ch*1.67);
}else if (marks > 53 && marks < 57){
printf("Your Cgpa of %s is 1.33 and your grade is D+\n",&course);
sum+=(ch*1.33);
}else if (marks > 49 && marks < 54){
printf("Your Cgpa of %s is 1.00 and your grade is D\n",&course);
sum+=(ch*1.00);
}else if (marks < 50){
printf("Your Cgpa of %s is 0.00 and your grade is F\n",&course);
sum+=(ch*0.0);
}
}
gpa=sum/total_ch;
printf("Your total GPA of this semester is %f",gpa);
}