Q:

OpenGL drawing Inverted Triangle

My triangle vertices are in array vertices that are specified in such a way that I should get an upright triangle but my triangle is inverted around y axis.
The code is below.
This is some Global stuff
#include<GL\glew.h>
#include<GL\freeglut.h>
#include<glm.hpp>
#include<gtc\matrix_transform.hpp>
#include<string>
#include<fstream>
#include<iostream>
using namespace std;

GLfloat vertices[] = {
    -1,-1,
    1,-1,
    0,1
};

GLuint vaoId;
GLuint vboId;

glm::mat4 projectionMatrix = glm::perspective(50.0f, 1.0f / 1.0f, 5.0f, 
20.0f);
glm::mat4 modelViewMatrix = glm::translate(glm::mat4(1), glm::vec3(0, 0, -20));

string parseShader(string fileName) {
    string shaderCode;
    ifstream ifs;
    ifs.open(fileName, ios::in);
    string line;
    while (!ifs.eof()) {
        getline(ifs, line);
        shaderCode += line;
        shaderCode += "\n";
    }
    return shaderCode;
}

GLuint program;

This function just loads shaders
void loadShader() {
    string vShader = parseShader("vShader.txt");
    GLuint vShaderId = glCreateShader(GL_VERTEX_SHADER);
    const GLchar* vShaderSource = vShader.c_str();
    glShaderSource(vShaderId, 1, &vShaderSource, NULL);
    glCompileShader(vShaderId);
    GLint compileStatus;
    glGetShaderiv(vShaderId, GL_COMPILE_STATUS, &compileStatus);
    if (!compileStatus) {
        cout << "Cannot compile shader\n";
        glDeleteShader(vShaderId);
        return;
    }

    string fShader = parseShader("fShader.txt");
    GLuint fShaderId = glCreateShader(GL_FRAGMENT_SHADER);
    const GLchar* fShaderSource = fShader.c_str();
    glShaderSource(fShaderId, 1, &fShaderSource, NULL);
    glCompileShader(fShaderId);
    glGetShaderiv(fShaderId, GL_COMPILE_STATUS, &compileStatus);
    if (!compileStatus) {
        cout << "Cannot compile fragment Shader\n";
        glDeleteShader(fShaderId);
        return;
    }

    GLuint programId;
    programId = glCreateProgram();
    glAttachShader(programId, vShaderId);
    glAttachShader(programId, fShaderId);
    glLinkProgram(programId);
    GLint linkStatus;
    glGetProgramiv(programId, GL_LINK_STATUS, &linkStatus);
    if (!linkStatus) {
        cout << "Cannot link program\n";
        glDeleteShader(vShaderId);
        glDeleteShader(fShaderId);
        glDeleteProgram(programId);
        return;
    }
    glUseProgram(programId);
}

This loads data in VBO
void loadDataInBuffers() {
    glGenBuffers(1, &vboId);
    glBindBuffer(GL_ARRAY_BUFFER, vboId);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
}

This function is used to bind states to VAO
void loadVao() {
    glBindBuffer(GL_ARRAY_BUFFER, vboId);
    glGenVertexArrays(1, &vaoId);
    glBindVertexArray(vaoId);
    glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);
    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);
}

This is rendering function
void display() {
    glClear(GL_COLOR_BUFFER_BIT);
    glBindVertexArray(vaoId);
    glDrawArrays(GL_TRIANGLES, 0, 3);
    glutSwapBuffers();
}

This calls all other functions defined above
void init() {
    glClearColor(0, 0, 0, 0);
    loadDataInBuffers();
    loadShader();
    loadVao();
    glUniformMatrix4fv(1, 1, GL_FALSE, &projectionMatrix[0][0]);
    glUniformMatrix4fv(2, 1, GL_FALSE, &modelViewMatrix[0][0]);
}

My main Method looks like this
int main(int argc, char** argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
    glutInitWindowSize(500, 500);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Simple Window");
    glewInit();
    init();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

Below is the vertex Shader
#version 430

layout(location = 0) in vec2 pos;
layout(location = 1) uniform mat4 projectionMatrix;
layout(location = 2) uniform mat4 modelViewMatrix;

void main(){
    vec4 position = vec4(pos,0,1);
    gl_Position = projectionMatrix*modelViewMatrix*position;
}

Below is the Fragment Shader
#version 430

void main(){
    gl_FragColor = vec4(1,0,0,1);
}

This is what I get

Shouldn't I get something like this

A:

EDITED:
It looks like you're running into the problem described here: https://www.opengl.org/discussion_boards/showthread.php/185661-glm-perspective-inverts-image
glm::mat4 projectionMatrix = glm::perspective(50.0f, 1.0f / 1.0f, 5.0f, 20.0f);

You've specified the angle (50.0) in degrees; it should be in radians. 50 radians is a weird number and probably not what you want.
Apparently the units for this function are not well-documented (I can't get to the doc site, so I don't know). Replace 50.0 with whatever it is in radians and see if that works.
glm::mat4 projectionMatrix = glm::perspective(50.0f * M_PI / 180.0f, 1.0f / 1.0f, 5.0f, 20.0f);

