alessandro
What?
Nur Mohammad
am new member in this group, i study EEE department. and i want to learn C program. How do i learn C program?
Deepak Chaurasia
Deepak Chaurasia
It happens due to maths practice 😂
Hello, I need a blas ?gemm(a[i,k] = sum_j b[i,j] c[j,k]) like function: a[i,k,x] = sum_j b[i,j,x] c[j,k,x] , is there any function can do it?
Is there any library implement such a function?
alessandro
I know function, called accumulate in c++ if you want sum numbers inside array
Yashraj Yadav
It happens due to maths practice 😂
tf , I thought you practicing some kind of advanced c lol
Secure human
I searched on the Net about opencv (for c), but I did not understand if i have tô install in my PC or if i have tô put in C with the terminal in some way
Thadeu
I have two kinds of data: const char * char * I'm writting a function that will receive one of them alternately and return char * Inside of function I will handle different operations on a copy of received string. How should be signature? char *x ( char *str ); or char *x ( void *str ); ?
alessandro
It's not possible put void as type of argument
Thadeu
yes... the compiler warns on using const char as char... so passing as void would receive anything and would cast only inside the function as (char *)
Thadeu
(void *) is basically any kind of pointer without type limitation
Thadeu
I would always prefer a specific type pointer over void* if possible and only use void* if it's some raw data that can be different things depending on some dynamic conditions
yes this is why I'm asking... sometimes I will pass const char, some times only char. I could write two functions, but due to memory allocation on copy and manipulation, it is better to have in a single function. So is my doubt.
Pavel
The question is, are you sure you need nonconst char* here?
Because modifying const char* may lead to crashes if it's some string from const memory (in C++ it's UB, not sure if it's in C)
Thadeu
Yes as const expect to not modify the pointer value... but I will use it to inner copy (to avoid the trouble you refer)
Pavel
So you need only one version
Pavel
If I understand you correctly
Thadeu
yes... You understood! It is the kind of thing in C we have no examples, just follow intuition.. but there are some forks, so is always good have a different opinion. Thank you much!!!
Pavel
yes... You understood! It is the kind of thing in C we have no examples, just follow intuition.. but there are some forks, so is always good have a different opinion. Thank you much!!!
Good thing in C++, that it won't actually compile code that has inconsistent constness or if you try to modify something const :)
Ludovic 'Archivist'
Good thing in C++, that it won't actually compile code that has inconsistent constness or if you try to modify something const :)
I wrote in my students lesson in the boldest shiniest font that if they ever use const_cast they are probably doing something very wrong
Ludovic 'Archivist'
They asked why I put it in the lesson if it is wrong
Ludovic 'Archivist'
Well, "so that [they] can look at whoever uses it with eyes of anger and confusion" was my answer
klimi
awesome
klimi
but in some cases it may make a little bit of sense
Ludovic 'Archivist'
but in some cases it may make a little bit of sense
Well, if you cast away const and do not want undefined behaviour, you may have to cast volatile in too
Ludovic 'Archivist'
Otherwise, your const value may never be truly updated
klimi
Well, if you cast away const and do not want undefined behaviour, you may have to cast volatile in too
well in some cases you know if it is const or not, but you can disregard this, code the function once and then recast if it doesn't break up :D
Faramarz
Do you know which option is correct for this question? I chose D, but I am not sure which option is right and why👇 You are using the assignment operator to assign a value to variable a and the expression on the right side is not evaluating to the value you expect. What is a possible cause? A) An equality was evaluated after a bitwise OR operation where the equality was to the left of the bitwise OR. B) The assignment operator appeared to the left of an equality operator. C) Assignment operators have right to left associativity and you thought it was left to right. D) Any of these could explain the issue.
Asker
Hello everyone
Asker
#include<iostream> #include<cmath> using namespace std; int main(){ int a,b,n; cin>>a>>b; n=(a+b)/2; if ( a<pow(10,9)) && b<pow(10,9)) cout<<n; }
Asker
I cant find the problem in this code
Anonymous
I cant find the problem in this code
You may search it in google assistant👈
Asker
Ok İ am trying it now
Anonymous
But how?
Write down your problem firstly in google search
~
Hello friends. I am a computer student and I am interested in hacking. If you can guide me where and what to start for the beginning. I want to start from zero. Please share your experiences with me. Thank you.
Mohamed Ahmed
Wrong answer test 2
Mohamed Ahmed
int main () { int t ; cin >>t; while (t--) { ll a , b ; int c =-1 ,sum = 0; cin >> a >>b; for (int i = a; i<=b;i++) { int lucky = 0 , x = i; while(x) { if (x%10!=4 && x%10 !=7) lucky ++; x=x/10; } if (lucky == 0) { sum+=i; c++; } } cout <<sum<<endl; } return 0; }
Mohamed Ahmed
Given two numbers A , B. Print the summation of digits of all lucky numbers between A , B inclusive. Input First line contains a number T (1≤T≤100) number of test cases. Next T lines contain two numbers A , B (1≤A,B≤1018). It's guaranteed that |A−B| does not exceed 10 ^ 4 . Output For each test case , print the summation of digits of all lucky numbers between A , B
Mohamed Ahmed
The lucky number is any positive number that its decimal representation contains only 4 and 7. For example: numbers 4, 7, 47 and 744 are lucky and numbers 5, 17 and 174 are not.
Arnold
good luck sir
Arnold
you can easily find the next lucky number from a particular previous lucky number
Arnold
the only tricky part (and very fun part) is quickly finding the first lucky number after A but it's similar to the previous case
Arnold
you can look at your lucky numbers as binary numbers, but instead of 1s and 0s you have 4s and 7s. Maybe this representation will help you to iterate through them. 0, 1, 10, 11, 100...
Dima
gtfo trader
Manuel
Hi i have 2 files connected via header and because of that the second file compiles before my main file and all the variables in it which i have definitions for them in my main file, what can i do? I compiles and says the variables are undeclared
Hi Itmar, in your compilation command you have to put the files in the right order, otherwise the linker will provide a file to the compiler in which the variable declaration can be after their use
Manuel
Or you go through all the sizes, take all the combinations of 4 and 7 at every position and adds
Billionaire
Hello
Billionaire
#include<stdio.h> #include<string.h> void reverse(char str[]) { int len=0; int i; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { len++; } char rev[200]; for(i=len-1;i>=0;i--) { rev[len-i-1]=str[i]; } printf("\nReverse is : %s",rev); } void characters(char str[]) { int len=0; int i; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { if(str[i] !=' ') len++; } printf("\n No of characters are :%d",len); } void copy(char str[]) { int len=0; int i; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { len++; } char rev[200]; for ( i = 0; str[i]!='\0'; i++) { rev[i]=str[i]; } printf("\n New String is :%s",rev); } void vowels(char str[]) { int i,vow=0; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { if(str[i]=='a' str[i]=='e' str[i]=='i' str[i]=='o' str[i]=='u' str[i]=='A' str[i]=='E' str[i]=='I' str[i]=='O' str[i]=='U' ) vow++; } printf("\n No of vowels in the string is : %d",vow); } void consonant(char str[]) { int i,con=0,len=0; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { len++; } for ( i = 0; str[i]!='\0'; i++) { if(str[i]== 'a' str[i]=='e' str[i]=='i' str[i]=='o' str[i]=='u' str[i]=='A' str[i]=='E' str[i]=='I' str[i]=='O' str[i]=='U' || str[i]==' ' ) con++; } printf("\n No of consonants in the string is : %d",len-con); } void aplhabet(char str[]) { int count=0,i; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { count++; } for (int i = 0; i < count; i++) { for (int j = i + 1; j < count; j++) { if (str[i]+1 > str[j]+1 ) { char temp; temp= str[i]; str[i]= str[j]; str[j]= temp; } } } printf("\n %s",str); } int main() { int ch; char str[100]; char sel='y'; printf("\n1.Reverse the string\n"); printf("\n2.Count the no. of characters in a string\n"); printf("\n3.Copy one string from another string\n"); printf("\n4.Count no of vowels\n"); printf("\n5.Count no of Consonants and no of punctuations\n"); printf("\n6.Arrange in Alphabetical ordeer\n"); printf("\n enter your choice :: "); scanf("%d",&ch); switch (ch) { case 1: reverse(str); break; case 6: characters(str); break; case 2: copy(str); break; case 3: vowels(str); break; case 4: consonant(str); break; case 5: aplhabet(str); break; default: printf("\n Wrong choice entered"); } return 0; }
Billionaire
#include<stdio.h> #include<string.h> void reverse(char str[]) { int len=0; int i; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { len++; } char rev[200]; for(i=len-1;i>=0;i--) { rev[len-i-1]=str[i]; } printf("\nReverse is : %s",rev); } void characters(char str[]) { int len=0; int i; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { if(str[i] !=' ') len++; } printf("\n No of characters are :%d",len); } void copy(char str[]) { int len=0; int i; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { len++; } char rev[200]; for ( i = 0; str[i]!='\0'; i++) { rev[i]=str[i]; } printf("\n New String is :%s",rev); } void vowels(char str[]) { int i,vow=0; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { if(str[i]=='a' str[i]=='e' str[i]=='i' str[i]=='o' str[i]=='u' str[i]=='A' str[i]=='E' str[i]=='I' str[i]=='O' str[i]=='U' ) vow++; } printf("\n No of vowels in the string is : %d",vow); } void consonant(char str[]) { int i,con=0,len=0; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { len++; } for ( i = 0; str[i]!='\0'; i++) { if(str[i]== 'a' str[i]=='e' str[i]=='i' str[i]=='o' str[i]=='u' str[i]=='A' str[i]=='E' str[i]=='I' str[i]=='O' str[i]=='U' || str[i]==' ' ) con++; } printf("\n No of consonants in the string is : %d",len-con); } void aplhabet(char str[]) { int count=0,i; printf("\nEnter the string:: "); gets(str); for ( i = 0; str[i]!='\0'; i++) { count++; } for (int i = 0; i < count; i++) { for (int j = i + 1; j < count; j++) { if (str[i]+1 > str[j]+1 ) { char temp; temp= str[i]; str[i]= str[j]; str[j]= temp; } } } printf("\n %s",str); } int main() { int ch; char str[100]; char sel='y'; printf("\n1.Reverse the string\n"); printf("\n2.Count the no. of characters in a string\n"); printf("\n3.Copy one string from another string\n"); printf("\n4.Count no of vowels\n"); printf("\n5.Count no of Consonants and no of punctuations\n"); printf("\n6.Arrange in Alphabetical ordeer\n"); printf("\n enter your choice :: "); scanf("%d",&ch); switch (ch) { case 1: reverse(str); break; case 6: characters(str); break; case 2: copy(str); break; case 3: vowels(str); break; case 4: consonant(str); break; case 5: aplhabet(str); break; default: printf("\n Wrong choice entered"); } return 0; }
why it is not taking input?
Anonymous
why it is not taking input?
You mean that "scanf("%d",&ch);" doesn't work?
NebAbdi
Guys can you help me complete the following function please🙏 Def XOR (a,b) # both a and b are booleans # if both are equal return true # else return false
NebAbdi
Anyone?🥲
西琳
I can't
Doreece
Hi. Can anyone explain how should I solve Time Limit Exceeded Error ?
klimi
Hi. Can anyone explain how should I solve Time Limit Exceeded Error ?
I don't think such error exists. Where did you get that?
klimi
I don't think they were asking for debugger. (I think it was for IDE)
Doreece
I don't think such error exists. Where did you get that?
You’re right The platform I should give my code to it ,gives this error because of time limit
klimi
You’re right The platform I should give my code to it ,gives this error because of time limit
OH! That's completely different case then. Your program/algorithm is slow.
klimi
So I should change it completely?
Depends on the problem, on the decomposition, how you currently feel etc... it's up to you