Is main function mandatory in glsl shaders?

C++ please help..I made squrea in main, I need to re-do that assignment with using function?

  • Re-write your Squares program so that it uses the following functions. int getInput(void); //function prototype This function prompts the user to enter an integer. After extracting data from cin, if cin.fail() is true, then print an error message and return -1. If a negative integer is entered, then print an error message and re-prompt the user; otherwise, return the integer. If getInput() returns a -1, then the calling function should print the number of squares printed along with their average length using the printStats() function and terminate the program. void printLine(char, char, int); //function prototype This function prints a line for the square. The first char parameter is the end character. The second char parameter is the interior character. The third parameter is the line length. Example usage. int length = ...; //variable storing the square length // print top line printLine('+', '-', length); // print interior line printLine('|', ' ', length); void printStats(int, int); //function prototype This functions prints the number of squares printed and their average length. The first int parameter is the number of squares printed. The second int parameter is the total of the printed square lengths. This function prints a line having the following format. X squares printed. Average length: Y.YY and here is my squares assingment #include <iostream> using namespace std; int main(void){ int s,n; do{ cout << "Enter length between 0 and 64 (-1 to exit):" ; cin >> s; cout << "Length entered :"<< s <<endl; if (s<-1 || s>64 ){ cout << s <<" is invalid" <<endl; cout <<"Length must be between 0 and 64 inclusive, or enter -1 to exit\n"; continue; } if(s==-1) break; if(s==0){ cout <<" " <<endl; } int p=1; while( p<=s){ cout << ((p==1 || p==s)? '+':'|'); for( n=2 ;n<s;n++) cout << ((p==1 || p==s)? '-':' '); if(s>1) cout << ((p==1 || p==s)? '+':'|'); cout <<endl; p++; } }while(true); system("pause"); return 0; }

  • Answer:

    That's because your variables weren't set up properly. Try adding some new variables.

Lebron at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.