Suppose I do something like this
Code: Select all
#include<iostream.h>
#define NUM 15
#define DEN 6
int main(){
int e;
e=NUM/DEN;
char array[e];
.
.
.
.
return 0;
}
Please help me with this
Thank you very much
Code: Select all
#include<iostream.h>
#define NUM 15
#define DEN 6
int main(){
int e;
e=NUM/DEN;
char array[e];
.
.
.
.
return 0;
}
gcc is clever. It sees that NUM and DEN are both constants and computes the value of "e" at compile time. when it gets to the line where you declare the array, the value of "e" is known and fixed. This means it is as though you had typed in a constant and thus there is no issue with how much space to provide.mahaju wrote:Hi everyone
Suppose I do something like thisPlease help me with thisCode: Select all
#include<iostream.h> #define NUM 15 #define DEN 6 int main(){ int e; e=NUM/DEN; char array[e]; . . . . return 0; }
Thank you very much
Code: Select all
i=0;
while (i<10) i++
Code: Select all
i=10
Code: Select all
#include<iostream.h>
#define NUM 15
#define DEN 6
int main(){
int e;
cout<<"Enter e>> ";
cin>>e;
char array[e];
return 0;
}
Code: Select all
#include <string>
#include<iostream>
using namespace std;
int main()
{
string s1;
string s2;
cout << "Enter a word:";
cin >> s2;
s1 += s2;
cout << "\nEnter another word:";
cin >> s2;
s1 += s2;
cout << s1 << endl;
return s1.size();
}