Yazidi
but i = 0 !
Yazidi
what should i do?!
Roshan
Roshan
So the name counting will start from 1
Yazidi
but i want the first element of the array
Yazidi
so that i want it to be 0 in the beginning
Yazidi
is there a trick to do?
Roshan
so that i want it to be 0 in the beginning
for (int i=0 ; i<num; i++)
{
cout << "Enter studen's name (" << i << "): ";
cin >> student[i];
cout << "Enter student's score (" << i << "): ";
cin >> score[i];
cout << endl;
}
Roshan
Yazidi
thanks a lot
Roshan
Anonymous
is usleep_range accurate for 1 ms ? I used msleep before ,but is not accurate for 1ms .After using ftrace and perf tracing ,I recognized it sleep the thread 20 ms not 1 ms .So,which is the most accurate function to sleep thread 1 ms in kernel ?
Adex
I want to learn c++ who will teach me
Adex
Yj
Adex
Teach me na
klimi
i don't know what "Yj" and "na" is
Adex
I want to learn
Roshan
I want to learn
https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb
Swapnil
that void view cart function is not working
Swapnil
Process exited after 64.04 seconds with return value 3221225477
Swapnil
😭
olli
Swapnil
im now to c++ bro
Swapnil
new*
Swapnil
rose shutup😂
Swapnil
tr told me to do that way
olli
Without knowing what you're trying to do it's hard to tell what's wrong (apart from syntax errors).
Xudoyberdi
😁
Roshan
PaAaAria
Hi everyone
I have a differential equation. I've used euler method and heun method to solve it but the codes give me different answers, could anybody help me to Fix this problem?
Anonymous
What is the back ground of c,c++..
Anonymous
Historically? C was developed to make it easier to develop complex systems such as operationg systems and have a general purpose language that was higher level. Other higher level languages at that time where very narrow in scope. C++, from what i know bjarne wanted to have a safer version of c. But it supported object oriented programming as well, which was a new and rising concept at the time and i think greatly helped to its success. People critical towards object orientation (at the time some argued that through the abstraction there would be a too big performance loss and other arguments... ) mostly stayed with C. And it is still used for embeded systems until this day because it is "easy" to write a compiler for and has very little overhead. But thats just all out of memory and things i heared so dont quote me on any of this 😅
Anonymous
Anonymous
Or even less
g3rm4n
hey, how can I call a function 3 times with a "for" loop
Anonymous
For example Jason Turner wanted to rewrite Doom to C++
Actually it was really hard task
And the only thing he did was just fixing compiler errors
And after he fixed the errors, a benchmark he had ran faster than on the original version
Roshan
Igor🇺🇦
Roshan
Roshan
Show code...
g3rm4n
printf("\n\nPlease enter first string:\n\n");
char FirstString[STR_SIZE] = { "Abc 123 $#& cDE AAA" };
fgets(FirstString, STR_SIZE, stdin);
FirstString[strlen(FirstString) - 1] = '\0'; // cut the " \n " after the string
for (int i = 0; i <=3; ++i) {
rotate_right(FirstString);
}
puts(FirstString);
I need to move 3 words from the end of the string to the beginning
g3rm4n
it moving only one word..
Roshan
g3rm4n
yeah i know, i put equal sign by mistake
Roshan
Promise
Anonymous
#include<stdio.h>
int sum(int num1,int num2);
int mul(int num1,int num2);
int div(int num1,int num2);
int sub(int num1,int num2);
int main()
{
float num1,num2;
char op;
printf("Enter First Number:");
scanf("%f",&num1);
printf("Enter your operation:");
scanf(" %c",&op);
printf("Enter Second Number:");
scanf("%f",&num2);
if(op=='+')
{
sum(num1,num2);
}
else if(op=='*')
{
mul(num1,num2);
}
else if(op=='-')
{
sub(num1,num2);
}
else if(op=='/')
{
div(num1,num2);
}
return 0;
}
int sum(int num1,int num2)
{
printf("Sum is %d",num1+num2);
return num1+num2;
}
int mul(int num1,int num2)
{
printf("product is %d",num1*num2);
return num1*num2;
}
int sub(int num1,int num2)
{
printf("Subtraction is %d",num1-num2);
return num1-num2;
}
int div(int num1,int num2)
{
printf("division is %d",num1/num2);
return num1/num2;
}
When I say bgd how can some study ?
Yazidi
#include <iostream>
#include <string>
using namespace std;
void info(string [] , double []int&);
void print(string[], double[], int);
int main ()
{
int num;
cout << "How many students do you have? ";
cin >> num;
cout << endl;
string student[num];
double score[num];
info(student, score, num);
print(student, score, num);
return 0;
}
// to get information of students..
void info (string& student[], double& score[], int& num)
{
for (int i=0; i<num; i++)
{
cout << "Enter studen's name (" << i+1 << "): ";
cin >> student[i];
cout << "Enter student's score (" << i+1 << "): ";
cin >> score[i];
cout << endl;
}
}
// to calculate the lowest score..
void print(string student[], double score[], int num)
{
for (int j=0; j<num; j++)
{
for (int i=0; i<num; i++)
{
int min;
if (score[i] > score[i+1])
{
min = score[i];
score[i] = score[i+1];
score[i+1] = min;
}
}
}
cout << student[0] << " , " << student[1];
}
Yazidi
#include <iostream>
#include <string>
using namespace std;
void info(string [] , double []int&);
void print(string[], double[], int);
int main ()
{
int num;
cout << "How many students do you have? ";
cin >> num;
cout << endl;
string student[num];
double score[num];
info(student, score, num);
print(student, score, num);
return 0;
}
// to get information of students..
void info (string& student[], double& score[], int& num)
{
for (int i=0; i<num; i++)
{
cout << "Enter studen's name (" << i+1 << "): ";
cin >> student[i];
cout << "Enter student's score (" << i+1 << "): ";
cin >> score[i];
cout << endl;
}
}
// to calculate the lowest score..
void print(string student[], double score[], int num)
{
for (int j=0; j<num; j++)
{
for (int i=0; i<num; i++)
{
int min;
if (score[i] > score[i+1])
{
min = score[i];
score[i] = score[i+1];
score[i+1] = min;
}
}
}
cout << student[0] << " , " << student[1];
}
this is a c++ program to get the score of students and display the lowest 2 scores
but I don't why the result is wrong !!😢
please help me
Roshan
#include <iostream>
#include <string>
using namespace std;
void info(string [] , double []int&);
void print(string[], double[], int);
int main ()
{
int num;
cout << "How many students do you have? ";
cin >> num;
cout << endl;
string student[num];
double score[num];
info(student, score, num);
print(student, score, num);
return 0;
}
// to get information of students..
void info (string& student[], double& score[], int& num)
{
for (int i=0; i<num; i++)
{
cout << "Enter studen's name (" << i+1 << "): ";
cin >> student[i];
cout << "Enter student's score (" << i+1 << "): ";
cin >> score[i];
cout << endl;
}
}
// to calculate the lowest score..
void print(string student[], double score[], int num)
{
for (int j=0; j<num; j++)
{
for (int i=0; i<num; i++)
{
int min;
if (score[i] > score[i+1])
{
min = score[i];
score[i] = score[i+1];
score[i+1] = min;
}
}
}
cout << student[0] << " , " << student[1];
}
Roshan
#include <iostream>
#include <string>
using namespace std;
void info(string [] , double []int&);
void print(string[], double[], int);
int main ()
{
int num;
cout << "How many students do you have? ";
cin >> num;
cout << endl;
string student[num];
double score[num];
info(student, score, num);
print(student, score, num);
return 0;
}
// to get information of students..
void info (string& student[], double& score[], int& num)
{
for (int i=0; i<num; i++)
{
cout << "Enter studen's name (" << i+1 << "): ";
cin >> student[i];
cout << "Enter student's score (" << i+1 << "): ";
cin >> score[i];
cout << endl;
}
}
// to calculate the lowest score..
void print(string student[], double score[], int num)
{
for (int j=0; j<num; j++)
{
for (int i=0; i<num; i++)
{
int min;
if (score[i] > score[i+1])
{
min = score[i];
score[i] = score[i+1];
score[i+1] = min;
}
}
}
cout << student[0] << " , " << student[1];
}
See the bold text
Roshan
Also the one below it... Imagine i is now at the last element. Then what is at score[i+1] ??
Roshan
Lava
Am I allowed to ask improvements for a small code also am I allowed to send the question link from a site ?
Yazidi
PaAaAria
ofstream command does not work is this code, does anybody know the reason?
#include <iostream>
#include <cmath>
#include <cmath>
#include <fstream>
using namespace std;
int main ()
{
ofstream myfolder ("Rung-kutta-second order.txt");
double x1,x2,a,b,h,y1,y2,y,k1,k2,f1,f2,y_new,x0;
int n;
a=0; b=2;h=0.1;n=(b-a)/h; y1=b;
x0=a;
for (int i=1;i<=n; i++)
{
x1=x0;
f1=y1-pow(x1,2)+1;
k1=h*f1;
x2=x0+h;
y2=y1+k1;
f2=y1-pow(x2,2)+1;
k2=h*f2;
y_new=y1+(k1+k2)/2;
cout<<x2<<"\t"<<y_new<<endl;
myfolder<<x2<<"\t"<<y<<endl;
y1=y_new;
x0=x2;
}
myfolder.close ();
return 0;
}
Anonymous
固定规则
**您无权获得答案,对未回答的问题生气会警告您。
*不检查您在Google(或任何其他搜索引擎) 中的问题 ) 首先会警告您。
*要求解决作业
测试
其他
Rules pinned
* You are not entitled to an answer, getting angry about not answered questions will get you warned.
* Not checking your problem in google (or any other search engine) first will get you a warn.
* Asking to solve an assignment
test
whatever
(达到长度限制,请私聊翻译全文)
Maxat
good evening i am a new member of the group :)
Xudoyberdi
Ishank
Hey how many are from outside India ?
Roshan
Ishank
Anonymous
Roshan
Anonymous
I'm from Brazil
Anonymous
Ok for studing this subject what some body intended to do?
Xudoyberdi
Dark
someone help me how to normalise the data within array from 0 to 255 not exceed value when something added on it
Array is 2d
Anonymous
hi
Anonymous
By this could I be matured enough to study further
Xudoyberdi
Dark
i don't know how to use if statement with 2d array