I have submitted my discussion question response online and queried the instructor who cannot help me because his "compiles fine". I need some help with where to get help with visual studio and learning c++
The textbook we were provided uses "namespace std". We are not allowed to use it. I have tried all types of while loops in the text book and all I have been able to accomplish is std::cout "Enter a number: " and I can enter a number (when that was in the code... I took it out).
This was the discussion question:
Suppose that the input is 0 0 8 12 50 7 13 -1. What is the output of the following code:
int num, sum, count;
cin >> sum;
cin >> count;
cin >> num;
while (count <= 4)
{
sum = sum + num;
count++;
cin >> num;
}
cout << "Sum = " sum << endl;
#include <iostream>
#include <iomanip>
#include <fstream>
int main()
{
std::ifstream inFile; //input file stream variable
std::ofstream outFile; //output file stream variable
int num = 0;
int sum = 0;
int count = 0;
inFile.open("Unit1Question5.txt");
outFile.open("sum.out");
while (count <= 4)
{
sum = sum + num;
count++;
std::cin >> num;
}
std::cout << "Sum = " << sum << std::endl;
system("pause");
}
When I click debug, I get no errors but the ouput tab has:
'Unit1DiscussonQuestion5.exe' (Win32): Loaded 'C:\Users\12345\Desktop\C++ Projects\Unit1DiscussonQuestion5\Debug\Unit1DiscussonQuestion5.exe'. Symbols loaded. 'Unit1DiscussonQuestion5.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. 'Unit1DiscussonQuestion5.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. 'Unit1DiscussonQuestion5.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. 'Unit1DiscussonQuestion5.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140d.dll'. 'Unit1DiscussonQuestion5.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140d.dll'. 'Unit1DiscussonQuestion5.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. The thread 0x3eec has exited with code 0 (0x0). The thread 0x204c has exited with code -1073741510 (0xc000013a). The thread 0x3c9c has exited with code -1073741510 (0xc000013a). The thread 0x2308 has exited with code -1073741510 (0xc000013a). The program '[13620] Unit1DiscussonQuestion5.exe' has exited with code -1073741510 (0xc000013a).
You will be able to figure it out if you debug with breakpoints. Place multiple breakpoints and proceed to execute the code line by line. Here is a link from Microsoft about how to debug with breakpoints.
As for learning c++, maybe this tutorial helps. I hope this helps!
User contributions licensed under CC BY-SA 3.0