int i = 1;
STUPID_ASSIGNMENT:
printf("%d\n", i);
if(i < 100)
{
i++;
goto STUPID_ASSIGNMENT;
}
Is this the kind of assignment teachers like to give nowadays?
int i = 1;
STUPID_ASSIGNMENT:
printf("%d\n", i);
if(i < 100)
{
i++;
goto STUPID_ASSIGNMENT;
}
Is this the kind of assignment teachers like to give nowadays?
Take away all those semi-colons after the if and else-if statement:
if (score >= 85);
grade = 'A';
else if (score >= 75);
grade = 'B';
else if (score >= 65);
grade = 'C';
else if (score >= 55);
grade = 'D';
else
grade = 'F';
Hi welcome to the forum! Please post your questions under Tech Talk->Microsoft Windows or the relevant sub sections under it.
Are you sure your program runs fine? At the first glance, there's so many errors in it:
1. Your main function is passing uninitialized variables' values like index and insertItem into removeAt() and insertAT() functions.
2. Inside insertAt() function, index and insertItem are treated as local variables. That's very bad programming. If you don't intend to pass values, you should simply declare those as local variables instead of parameters.
3. In insertAt() function, the variable item is neither initialized nor assigned any values, yet it is used at the end of the function inside the loop. This leads to some undefined behaviour.
4. You only check once for invalid user input. You should use a loop such that the program will always prompt the user for inputs after each invalid inputs.
5. You use insertItem for the item to be inserted, and index for the position to be inserted. Yet in the below code you never used the variable index! You should used it as the index of the array.
numbers[insertItem-1] = insertItem;
cout<<numbers[insertItem-1]<<" ";
6. Even if you rectify for point number 5, it still doesn't achieve what you want. It merely overwrite the existing array item with the new item, instead of inserting the item into the position stated. To do what you want, all the subsequent array items must be pushed backwards. If you want to use integer array, then you need to manually "grows" the array to cater for the …
now im having issues on calculating these things
Amount deducted for prize money: $ 15000.00
Balance raised for charitable fund: $ 230000.00
What's the difficulty in calculating these two items? The first one is straight from the value the user entered, the second was just the total revenue deducting the admin fee & prize money.
and idk why but the setprecision is not working on
Revenue generated from ticket sales: $ 250000.00
it works fine for
Amount deducted for administrative overhead: $ 5000.00?????
That's because you are using integers. Alright, put a decimal point behind the number "5" and magic will appears.
When you are using the printf function:
printf("%s", a);
The function is treating variable "a" as a pointer to the beginning of a stream of characters. However, it doesn't have the information about how long the stream of characters is, it has no knowledge that "a" is defined as an array. Thus, the function will simply read from the beginning of the address that "a" points to, byte by byte, until it encounters the null character which indicates the end of a character string.
Integer, float and other types are not used to represent string.