Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed Need help on this, I don't know what I did wrong

+3 votes
asked Jun 8, 2021 by Andy Kok (150 points)
closed Sep 30, 2021 by Admin
#include <stdio.h>
#include <iosteam>
using namespace std;

int main()                                              // main function, takes no argument, return "int"
    int nX, nY;                                        // declare two int variables
    float fSalary = 13.48;                             // declare and initialize a float variable
    char cLetter = 'K';                                // declare and initialize a char variable
    nX = 25;                                           // assign a value to nX
    nY = 34;                                           // assign a value to nY
    int nZ = 25 + 34;                                  // declare nz and then initialize with (nX+ny)
    cout << "Here are my outputs: " << endl << endl;   // output a line of text
    cout << "Salary = " << fSalary << endl;            // output Salary
    cout << "Z = " << nZ << endl;                      // output z
    cout << "Letter = " << cLetter << endl;            // output Letter
    return 0;
closed with the note: answered

2 Answers

+2 votes
answered Sep 29, 2021 by nagaraju repala (180 points)
On the 2nd line use


instead of #include<iosteam>

you have missed a letter in stream
0 votes
answered Sep 30, 2021 by Peter Minarik (54,540 points)

Nagaraju Repala has already answered your question.

I would like to give you an advise: instead of using Hungarian Notation all the time try giving your variables meaningful names that tells what it is.

Yes, sometimes it may be helpful to have a hint for the type, but most of the time it is unnecessary and will make your code very hard to maintain on the long run.

Imaging you have a list that contains customers. You call this list listCustomer. Later, you decide to change the data type to vector. Now, you'd need to rename your variable to vectorCustomer. A proper meaningful names would be customers (notice the plural).

In your example, the salary may change to int or even double at some point.

nZ could be called sum while nX and nY just simply x and y.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.