#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <cmath>
usingnamespace std;
int rand_0toN1(int n);
void draw_the_list();
char *names[3] = { "L. Maimouna", "M. Antony", "H. Hamissou" };
char *scores[3] = { "94", "99", "100" };
int main()
{
int n;
int i;
srand(time(NULL));
while (1)
{
cout << "Enter the list number to draw a name.";
cout << "(o to exit):";
cin >> n;
if (n == 0)
break;
for (i = 1; i <= n; i++)
draw_the_list();
}
return 0;
void draw_the_list()
{
int u;
int s;
u = rand_0toN1(3);
s = rand_0toN1(3);
cout << names[n] << "of" << scores[s] << endl;
}
int rand_otoN1(int n)
{
return rand() % n; // It tells me n is not declared but I did in main
}
}
#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <cmath>
usingnamespace std;
int rand_0toN1(int n);
void draw_the_list();
char *names[3] = { "L. Maimouna", "M. Antony", "H. Hamissou" };
char *scores[3] = { "94", "99", "100" };
int main()
{
int n;
int i;
srand(time(NULL));
while (1)
{
cout << "Enter the list number to draw a name.";
cout << "(0 to exit):"; // I hope it was another error, I put o instead of zero.
cin >> n;
if (n == 0)
break;
for (i = 1; i <= n; i++)
draw_the_list();
}
return 0;
}
void draw_the_list()
{
int u;
int s;
u = rand_0toN1(3);
s = rand_0toN1(3);
cout << names[n] << "of" << scores[s] << endl;
}
int rand_otoN1(int n)
{
return rand() % n;
}
#include <iostream>
#include <ctime>
#include <cmath>
usingnamespace std;
int rand_0toN1(int n);
void draw_the_list();
char *names[3] = { "L. Maimouna", "M. Antony", "H. Hamissou" };
char *scores[3] = { "94", "99", "100" };
int main()
{
int n;
int i;
srand(time(NULL));
while (1)
{
cout << "Enter the list number to draw a name.";
cout << "(0 to exit):"; // I hope it was another error, I put o instead of zero.
cin >> n;
if (n == 0)
break;
for (i = 1; i <= n; i++)
draw_the_list();
}
return 0;
}
void draw_the_list()
{
int u;
int s;
u = rand_0toN1(3);
s = rand_0toN1(3);
int rand_otoN1(int u);
int rand_otoN1(int s);
cout << names[n] << "of" << scores[s] << endl;
}
int rand_otoN1(int n)
{
return rand() % n;
}
The errors:
Warning 1 warning C4627: '#include <iostream>': skipped when looking for precompiled header use
Warning 2 warning C4627: '#include <ctime>': skipped when looking for precompiled header use
Warning 3 warning C4627: '#include <cmath>': skipped when looking for precompiled header use
Error 4 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
5 IntelliSense: expected a ';'
6 IntelliSense: expected a declaration
Sorry if I confused you. I just copied in lines of your code to show the discrepancy in spelling. line 38 - you spell the function name differently there.
int rand_otoN1(int n) // <- typo in function name
You don't need all those lines in the function.
1 2 3 4 5 6 7 8 9 10
void draw_the_list()
{
int u;
int s;
u = rand_0toN1(3);
s = rand_0toN1(3);
int rand_otoN1(int u);
int rand_otoN1(int s);
cout << names[n] << "of" << scores[s] << endl;// <- this function doesn't know what n is. Did you mean to use one of the local variables you actually defined in the function?
}