Shubh Joshi
Hello everyone I m first year engineering student... Where can I get challenges for practice of C programming?
Golden Singh
for(int i=0;i<j;i++,j--) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } //when i=3,j=1 then 3<1 why are loop not stoping
Anonymous
Can someone share a Good Learning Path to Learning C++ (With Sample Projects that can get you hands on too)
Roman
Hello everyone I m first year engineering student... Where can I get challenges for practice of C programming?
You can use codewars. There are a lot of different tasks, which usual are related with algorithms.
Stefano
Guys I'm using ncurses for a project, I have a function that through forks generates a process that controls a spaceship, since I have to generate n spaceships (controlled by n processes) I tried to loop the function but the spaceships are generated overlapping. Could you explain to me how I can solve this problem? the code is here: https://pastebin.com/59zYdsxh
Kenny Jai
Hi everyone
Kenny Jai
Given an integer num, return the number of steps to reduce it to zero. In one step, if the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it. Example 1: Input: num = 14 Output: 6 Explanation: Step 1) 14 is even; divide by 2 and obtain 7. Step 2) 7 is odd; subtract 1 and obtain 6. Step 3) 6 is even; divide by 2 and obtain 3. Step 4) 3 is odd; subtract 1 and obtain 2. Step 5) 2 is even; divide by 2 and obtain 1. Step 6) 1 is odd; subtract 1 and obtain 0.
Kenny Jai
#include<stdio.h> int main(){ int num; int steps=0; printf("Please enter the number:"); scanf("%d",&num); while(num!=0){ num=(num%2==0)?num/2:num-1; steps ++;} return steps; }
Kenny Jai
i don’t know why no output
Kenny Jai
Can anyone help?Thanks.
Talula
You should return 0 as there is no error in the code.
Kenny Jai
Oic😮
Kenny Jai
Thank you
Talula
#include<stdio.h> int main(){ int num; int steps=0; printf("Please enter the number:"); scanf("%d",&num); while(num!=0){ num=(num%2==0)?num/2:num-1; steps ++;} return steps; }
#include<stdio.h> int main(){ int num; int steps=0; printf("Please enter the number:"); scanf("%d",&num); while(num!=0){ num=(num%2==0)?num/2:num-1; steps ++; printf("%d,%d\r\n",steps,num); } return 0; }
Kenny Jai
you can just !num % 2
Thank you also🙏🏻
Kenny Jai
How to modify my code🥲I just started to learn programming 🥲
Talula
What if I only want to show the number of steps at the end?But not showing all the steps? For example, enter 14 the output will be 6. Thanks.
#include<stdio.h> int main(){ int num; int steps=0; printf("Please enter the number:"); scanf("%d",&num); while(num!=0){ num=(num%2==0)?num/2:num-1; steps ++; } printf("%d\r\n",steps); return 0; }
Prince Fine
Guys I have a global declared values Int a = 2 , int b = 3 and int c = 3.2 And I have a func called int sum (int a, int b) { return a+b;} What if the user send sum(a,c) ; What can we say about it Ik it compile but what's the error
Anonymous
Please suggest me some topics for last year major project
coal
an integer is a number without a fractional component (i.e. 3.2 is not an integer)
coal
when you want to declare a number with a fractional component you use a floating point number (float) float c = 3.2; otherwise it just gets truncated to an integer int c = 3.2; // c is now equal to 3
Mike
Exercises Write a program that, having acquired a sequence of integer values ​​terminated by 0, evaluates the sum of the negative values ​​and the sum of the positive values ​​entered, and indicates which of the two is greater in absolute value. Write a program that displays a row of dashes. The row must be of a length equal to a value entered by the user, between a minimum of 12 and a maximum of 37.
coal
have you attempted solving it yourself first
Prince Fine
coal
nope
Mike
I do not know where to start
Anonymous
Hello there
Anonymous
Download mobile c on app store
coal
using [] is invalid syntax
Anonymous
Hello there
Anonymous
Any guidance on recursion
Mike
you know a site where he gives me the program done
Prince Fine
when you want to return an array you use "type*"
2 - I can't declare like that ? Why?
Anonymous
what
Some one requested an app for coding programs using c
coal
if you want to return an array you specify that you want to return a pointer
coal
Some one requested an app for coding programs using c
termux provides you with a literal shell so you can also compile C in it
coal
you know a site where he gives me the program done
i have copilot so this kind of autocompletion is common to me lol
Prince Fine
if you want to return an array you specify that you want to return a pointer
Can you give me the exact declaration for both problems pls 🙏
Mike
do you know a site that gives the program already done?
coal
the second one would be "float*" instead of "float[]"
coal
you're welcome
Anonymous
Anyone who knows batch language
Anonymous
Am looking forward to understanding it both with assembly language for robotics
Prince Fine
the second one would be "float*" instead of "float[]"
Ok that was on the function type what if it was on the parameters ? Is that the same
Anonymous
dontasktoask.com
Thanks for that..
coal
for example, you can use C/C++ with Arduino
coal
"float* fun(int* arrayofint) {}"
coal
you're welcome
Anonymous
for example, you can use C/C++ with Arduino
Ok sure but assembly language is the best for this one
coal
depends in your needs
Anonymous
dontasktoask.com
Not working for me ..
coal
i find C to have a footprint low enough to be used in embedded programming
coal
plus, there's way more support in C than in assembly
\Device\NUL
Different arch different register, and different kernel has different syscall
coal
if you're using some form of assembly then you're either really serious about performance or really restricted
Anonymous
plus, there's way more support in C than in assembly
Ohh thats right but am not good enough in c++