thanks guys,
doing it like
input(a,m,n)
worked...
Thanks for all the help...
thanks guys,
doing it like
input(a,m,n)
worked...
Thanks for all the help...
You can try going for Dell XPS or a Alienware..
Alienware are the meanest gaming machines (From Dell) or you can go for the XPS series if you want pro. work
and gaming.
I own a XPS 15 with
1 GB NVIDIA graphics with Optimus
15" Full HD screen
4 GB RAM
640 GB Hard-Disk
Hello,
I was having some trouble related to a code.
I wanted to pass a 2-D array as argument to a function,but I'm getting an error saying 'Expression Syntax in function Main'.
I am trying to do it like this :->
void input(int **a[][10],int b,int c)
{
int i,j;
printf("\nEnter the elements of the Array :-> ");
for (i=0;i<b;i++)
for (j=0;j<c;j++)
scanf("%d",&a[i][j]);
}
void main()
{
int a[10][10],b[10][10],c[10][10],i,j,k,choice,m,n;
printf("Enter the no. of rows and cols for A and B :-> ");
scanf("%d%d",&m,&n);
input(a[][10],m,n);
input(b[][10],m,n);
getch();
}
So,I wanted to know where am I wrong.
At some place I read that in C 2-D arrays can't be passed as arguments.
If so,how can I pass them??
Thanks In Advance
Chirag_Mittal
There is a single arithmetic operation you can use to convert the ranges 0-89, 90-179, 180-269, 270-359 into the values 0, 1, 2, 3, respectively. The result represents the quadrant; 0 would be the first quadrant.
@death_oclock
Thank you very much...
it solved my problem...
Thanks Again...
dear zeroliken,
that's where my problem started...
I have to use only switch statement..
dear gerard4143,
Thanks for the snappy reply.
I figured out what you are saying.But,the problem is that i can't go on writing all 360 cases for 360 values of an angle.
what I'm seeking is a solution for shortening the program length by somehow testing the condition in the case...
Is there any way of doing that??
I had the same problem playing Battlefield 3...
what i did was...
go to nvidia's driver download site..
Link :- http://www.nvidia.com/Download/index.aspx?lang=en-us
select the build of your graphic card and download the latest driver from there...
after you install it hopefully your problem will be solved...
Hello,
I was given a question a few few days back to write a program that lets a user enter a value for an angle and quadrant in which the angle lies is printed using switch statement.
I was able to make this program using if-else very easily but making it with switch statement is a problem..
I tried using
switch (angle)
{
case (angle>=0 && angle<=90):
printf("1st quadrant");
break;
.
.
.
.
}
and so on....(where angle is the variable in which the value of angle is stored )
it gives me the error "Case constant required in statement switch"...
it works if I write it like case 90:,case 45: and all other constant values..
but,i can't go writing all 360 cases for all angles,can I???
So,is there any way to check a condition in switch statement??
---
Thanks in advance..
Thanks to all of you guys...
I was able to successfully complete my project work..
all you guys just rock!!
Thanks to all of you guys...
I was able to successfully complete my project work..
all you guys just rock!!
Dear Fbody,
I read the link provided by you.
It tells me about various kinds of loops and all...
The thing is that I know these loops and I just want an example for the code above for how to replace the goto with some other loops...
the problem for me is that I have used way too many goto statements and I'm unable to think of a way to replace them..
all I want is a example of some section of the above code so that i can implement that example for the rest of the code...
thank you in advance....
Thank you guys for replying so quick but I also thought about that...
the thing is that I have used many and many goto statements and replacing them all with do..while loops is a messy work and I am getting it all wrong....
so can you pls tell how to use the loop in any one of the the functions???
plz....
Hello,
I am need of urgent help.I've made a program to generate bills (using goto statements) but my teacher has asked me to remove those and use something else in place of it.The problem is that I have tried using separate functions for that (It's not working properly) and I'm unable to think of any other way to correct.
Plz Plz Plz help me...
this is really urgent...
Thanks in advance...
Here's the original code...
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<iomanip.h>
//global variable declaration
int k=7,r=0,flag=0;
struct date
{
int mm,dd,yy;
};
ofstream fout;
ifstream fin;
class item
{
int itemno;
char name[25];
date d;
public:
void add()
{
cout<<"\n\n\tItem No: ";
cin>>itemno;
cout<<"\n\n\tName of the item: ";
gets(name);
cout<<"\n\n\tManufacturing Date(dd-mm-yy): ";
cin>>d.mm>>d.dd>>d.yy;
}
void show()
{
cout<<"\n\tItem No: ";
cout<<itemno;
cout<<"\n\n\tName of the item: ";
cout<<name;
cout<<"\n\n\tDate : ";
cout<<d.mm<<"-"<<d.dd<<"-"<<d.yy;
}
void report()
{
gotoxy(3,k);
cout<<itemno;
gotoxy(13,k);
puts(name);
}
int retno()
{
return(itemno);
}
};
class amount: public item
{
float price,qty,tax,gross,dis,netamt;
public:
void add();
void show();
void report();
void calculate();
void pay();
float retnetamt()
{
return(netamt);
}
}amt;
void amount::add()
{
item::add();
cout<<"\n\n\tPrice: ";
cin>>price;
cout<<"\n\n\tQuantity: ";
cin>>qty;
cout<<"\n\n\tTax percent: ";
cin>>tax;
cout<<"\n\n\tDiscount percent: ";
cin>>dis;
calculate();
fout.write((char *)&amt,sizeof(amt));
fout.close();
}
void amount::calculate()
{
gross=price+(price*(tax/100));
netamt=qty*(gross-(gross*(dis/100)));
}
void amount::show()
{
fin.open("itemstore.dat",ios::binary);
fin.read((char*)&amt,sizeof(amt));
item::show();
cout<<"\n\n\tNet amount: ";
cout<<netamt;
fin.close();
}
void amount::report()
{
item::report();
gotoxy(23,k);
cout<<price;
gotoxy(33,k);
cout<<qty;
gotoxy(44,k);
cout<<tax;
gotoxy(52,k);
cout<<dis;
gotoxy(64,k);
cout<<netamt;
k=k+1;
if(k==50)
{
gotoxy(25,50);
cout<<"PRESS ANY KEY TO …
Thanks for the suggestions and help.
It really helped me,but there were some things that I didn't understand (I am a new bee to c++ coding),like :->
1) as you said srand() must be declared early in the main(),my question is where as I declared it in the loadfile(),and it is called early in the main()....
2) where can I get the new free compilers,as u mentioned,I looked over and over again on the internet couldn't find it anywhere...please provide links if convenient to you..
Thank you.....
Hello friends, I need some help with my c++ hangman code.The code is below.
/*Game of Hangman
Author - Chirag Mittal */
#include<iostream.h> // For input/output
#include<fstream.h> // For file input/output
#include<string.h> // For strcpy
#include<time.h> // For time
#include<stdlib.h>
#include<ctype.h> //for toupper & tolower
#define MAX_WORD_SIZE 15 // The max size for words
#define MAX_WORDS 255 // The max number of words
void LoadFile(); // Prototypes for our functions
void RunGame();
void DrawGallows(int State);
typedef char String[MAX_WORD_SIZE]; // Make a char type with 15 chars
String Words[MAX_WORDS - 1]; // This array will hold our words
int Count; //word count
// the main function of our hangman game
void main()
{
char Continue = 'Y'; // end game if = to 'N'
cout<<"Welcome to Hangman . . . Don't lose your head!"<<endl;
LoadFile(); // Load the data file
// Continue the game as long as the player wants
while(Continue == 'Y')
{
RunGame(); // Run the game
cout<<endl<<"Do you want to play again (Yes or No)? ";
cin>>Continue;
Continue = toupper(Continue);
}
// say good bye
cout<<endl<<"Thanks for playing."<<endl;
}
// This will load our file
void LoadFile()
{
char C; //Used to find EOF
ifstream Datfile; //The in file
Count=0; //Set count to 0
// Open the data file
Datfile.open("words.dat");
//Loop till the end of file
while((C=Datfile.peek()) != EOF)
{
// Get the next word and then increment Count
Datfile>>Words[Count++];
// If we surpass the max exit and tell the user
if(Count > MAX_WORDS - 1)
{ …