Trying out a code to get all the possible marks that can be obtained in a GATE paper.
Assumptions taken :
1) All questions are MCQs (all questions have a chance of negative marking)
2) 30 1-mark questions, 35 2-mark questions
3) Static array without any memory constraint to hold the values of marks
4) Unoptimized solution: the array can have duplicate values of marks
Here is the basic code that I have come up with
#include <stdio.h>
int main()
{
float a[1000] = {0};
// 30 1-mark MCQ, 35 2-mark MCQ
int x,y,k=0;
float score;
for(x=-30;x<=30;x++)
{
for(y=-35;y<=35;y++)
{
if(x<0)
{
if(y<0)
score= 0.33*x + 0.66*y;
else
score= 0.33*x + 2*y;
}
else
{
if(y<0)
score= 1*x + 0.66*y;
else
score= 1*x + 2*y;
}
a[k]=score;
k++;
}
}
for(int i = 0; i<(sizeof(a)/sizeof(float)) ;i++)
printf("%f", a[i]);
return 0;
}
The console doesn't output anything.
Any suggestions on where might I be going wrong/ the error lies?