Leonardo
for this reason we should code in binary
Leonardo
(im joking)
Leonardo
anyway ill have a c exam in January😳🫣
Shaheer
.Write a program that inputs no of persons and their ages respectively. It then counts the no. of persons in age group 50 to 60. Please in c++
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
helllooo
touhou
helllooo
https://t.me/programminginc/481019
Leonardo
Mr
This is wrong.
I just fixed the code logic depends on the user
DaviChan
helllooo
Hello! I answered you already
DaviChan
https://t.me/programminginc/481019
Thanks, didnt see lol ✌
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
sorry
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
Thanks, didnt see lol ✌
the last comma only not the all commaa
touhou
the last comma only not the all commaa
Have you tried this as suggested my David L.?
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
yes
DaviChan
Okay, did it work? 🤔
Muhamad Khalid Muzappa
Anybody here developing C project under windows using mingw? I cant get dup(int fd1, int fd2) function to work under windows. It compiles without error, but dup2 just wont work. Anybody here having same problem?
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
Vlad
gotcha covered
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
all comma went gone
Muhamad Khalid Muzappa
_dup2
Thankyou sir. Will try. Does _dup2 works on MingW or i need to compile my code using Microsoft visual c++?
Vlad
Should work
DaviChan
all comma went gone
Can you show us what you wrote exactly? Screenshot is fine too
Muhamad Khalid Muzappa
_dup2 is from io.h which is a part of c runtime library on windows
Ok i need to include io.h. understood. Will try. Do i need to pass any argument to gcc to link to any additional library to use _dup2?
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
i cannot send image
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
Yes you can ^^ replace "%d," with i<n?"%d,":"%d"
#include <stdio.h> void main() { int arr[100]; int i,n; printf("\n\nEnter Size:"); scanf("%d",&n); for(i=1; i<=n; i++) { printf("Enter element %d : ",i); scanf("%d", &arr[i]); } printf("["); for(i=1; i<n; i++) { printf("%d", arr[i]); } printf("]"); }
DaviChan
Uhm
DaviChan
the whole line shhould be: printf(i<n?"%d,":"%d", arr[i]);
DaviChan
look up the "ternary operator" on cppreference for reference :)
DaviChan
This ofc. Is not the most "runtime efficient" way, but i quite like doing it that way
Baby
Hi, if i want to add a enum to a class. where do i declare it? I declare it within the class but it cant be accessed
Baby
i couldnt find examples on google. and also i am doing cpp on netbeans. the code is showing build errors
Olivia
#include <iostream> using namespace std; int main() { int number=6; // left arrow for (int i=0; i <= number; i++) { for (int j=0; j < number; j++) { if (i== number/2 i-j == number/2 i+j == number/2) cout <<"*"; else cout <<" "; } cout << endl; } return 0; } Please explain this how its work
Warlock
The if condition
No Logical Operators?
Olivia
it's a loop and a statement
Can u explain in detail too
Gregory
Can u explain in detail too
Which part are you still confused about?
Anonymous
#include <stdio.h> void main() { float weight, height, bodyWeightIndex; weight =80; height =1.5; printf("%d", 'weight\n'); scanf("%f", '&weight\n'); printf("hieght\n"); scanf("%f", '&height\n'); bodyWeightIndex=weight/(height*height); printf("Your body weight is%.2f\n",bodyWeightIndex); if (bodyWeightIndex>=25.0) printf("Your body weight is more than ideal weight.\n Try reducing\n" ); else printf("Congratulations! Your body weight is normal\n"); return 0; }
P
Dan is playing a video game in which his character competes in a hurdle race by jumping over hurdles. The game maintains a scorecard. It accepts the number of hurdles in the race, and the height of each hurdle. Write a program to simulate this. The program must display the heights of the last 5 hurdles that Dan jumps over. Note: Observe the highlighted output statements in the sample input and output statements for more clarifications. Do not change the code template given. Write your code in the provided places alone. Avoid the usage of exit(0) in your code. Input Format The first input is the no. of hurdles which should be >0 and <=100. The second input is the height of each hurdle. Output Format Print the heights of the last 5 hurdles scores which are stored in the scorecard. Sample input statement 1: Enter the no. of hurdles:8 Enter the hurdle height 1:6 Enter the hurdle height 2:2 Enter the hurdle height 3:5 Enter the hurdle height 4:3 Enter the hurdle height 5:6 Enter the hurdle height 6:9 Enter the hurdle height 7:5 Enter the hurdle height 8:7 Sample output statement 1: Latest hurdle race scores are: 3 6 9 5 7 Sample input statement 2: Enter the no. of hurdles: 6 Enter the hurdle height 1:5 Enter the hurdle height 2:1 Enter the hurdle height 3:4 Enter the hurdle height 4:6 Enter the hurdle height 5:4 Enter the hurdle height 6:8 Sample output statement 2: Latest hurdle race scores are: 1 4 6 4 8 Sample input statement 3: Enter the no. of hurdles:0 Sample output statement 3: Invalid no. of hurdles Sample input statement 4: Enter the no. of hurdles:101 Sample output statement 4: Invalid no. of hurdles Sample input statement 5: Enter the no. of hurdles:-1 Sample output statement 5: Invalid no. of hurdles
P
can anyone help me to solve it please
P
actually i am not able to go for the case <8
Anonymous
Chyo takoy
Can you speak English i dont understand you sorry
Anonymous
can anyone help me to solve it please
Anonymous
#include<iostream> using namespace std; const char STAR = *;const int PRIME = 7; void main;{int count, sum, x;count = 1; sum – count + PRIMEx = 25.67; newNum = count * ONE +2;sum + count = sum; x = x + sum * COUNT; cout <<”count =”<< count<< “; sum = “ << sum << “,PRIME=” << prime;
Anonymous
Your printf and scanf calls look very strange (the first ones, the last three printfs look OK) Why do you put weight into quotation marks?
Was jus trying to device a program im stil new to all this. So im trying out questions for practice
Pavel
Was jus trying to device a program im stil new to all this. So im trying out questions for practice
So when you put something into quotation marks it becomes a string, you shouldn't put variable names into quotation marks if you want them to behave like variables. In other words it should be printf("%f\n", weight); and scanf("%f", &weight);
Pavel
Oh i see, thank you so much. So is there any other changes i need to make there besides this
Besides printf and scanf I don't see issues, but I would compile it and see if the compiler will show any errors
Anupam2.7
question is to find the number of trailing zero of the factorial of the given number. sample input: 5, output: 1 I have written it's program in c++, it is working fine for small number, but in cause of input 100 it outputs 0. So, in these type of questions do I have to worry about large inputs? how can i fix this? the program: https://onlinegdb.com/PSW0JawAa
Pavel
question is to find the number of trailing zero of the factorial of the given number. sample input: 5, output: 1 I have written it's program in c++, it is working fine for small number, but in cause of input 100 it outputs 0. So, in these type of questions do I have to worry about large inputs? how can i fix this? the program: https://onlinegdb.com/PSW0JawAa
Usually yes, but in case of factorial it grows big really fast so I'm not sure if the catch is using a bigger type. 100! is a huge number, none of the standard type will be able to fit it as far as I know. Maybe there's a way to calculate only the truncated part of the number (you care only about trailing zeros, so probably you can truncate everything that doesn't fit int for example, not sure if it will work).
Faramarz
Can someone help me to understand the condition of this for loop please? How i < s[i] != '\0' works? void strToLower(char s[]) { for(int i=0; i<s[i] != '\0'; i++) s[i] = tolower(s[i]); }
Egro
guys
Egro
so i finally, comprehend, call by reference .... took me two days
Egro
Can someone help me to understand the condition of this for loop please? How i < s[i] != '\0' works? void strToLower(char s[]) { for(int i=0; i<s[i] != '\0'; i++) s[i] = tolower(s[i]); }
so, "! =" do you know what this mean? or any thing similar, like " +=" or "*=" ? if you dont know this short hand computation, you should learn about it. Learn and master this short hand computation and you will know what the loop means.
Suka
Can someone help me to understand the condition of this for loop please? How i < s[i] != '\0' works? void strToLower(char s[]) { for(int i=0; i<s[i] != '\0'; i++) s[i] = tolower(s[i]); }
the result of i < s[i] are true or false, 0 == false and "not 0" == true. and '/0' == 0 == false. for me i will type this way for (int i=0; ( i<s[i] ) != 0; i++) but what this line for? idk hehe
Iwan
Language: c Code: #include <stdio.h> #include <ctype.h> int main() { char s[]="AbcDeFGijkL"; for (int i=0;i<s[i] !='\0';i++) s[i]=tolower(s[i]); printf("%s",s); } Output: abcdefgijkl
Iwan
Language: c Code: #include <stdio.h> #include <ctype.h> int main() { char s[]="AbcDeFGijkL"; for (int i=0;i<s[i] !='\0';i++) s[i]=tolower(s[i]); printf("%s",s); } Output: abcdefgijkl
@Faramarz_aboutaleb after char L is '\0'. This called asciiz (the string followed by zero to know where is the end of string. So, it is work if you do s[i] != '\0'
Baby
Hii, uhh i have a very dumb question. can anyone please help? 😅😅 suppose a virtual class called User has two child classes "Teacher" and "Student" ; can Teacher class take in Students as a parameter of one of its function? 😅 Student has a function called void printDetails(); it returns cout all of student details. i want teacher to view student details too. void viewStudentDetails(Student *s){ s->printDetails(); }
Anonymous
question is to find the number of trailing zero of the factorial of the given number. sample input: 5, output: 1 I have written it's program in c++, it is working fine for small number, but in cause of input 100 it outputs 0. So, in these type of questions do I have to worry about large inputs? how can i fix this? the program: https://onlinegdb.com/PSW0JawAa
You don't have to calculate the factorial to find the number of trailing zeros. All that you have to do is find the number of times 5 occurs as a factor of the number. That will give you the number of trailing zeroes. For ex : 5! has one 5 as a factor. So there will be only 1 zero. 11! has 5 as a factor two times. So there will be two zeros 29! has 5 as a factor 6 times. So there will be 6 trailing zeros.
Thadeu
I have a question maybe too noob, are programming languages made by other languages? Pls🙏
yes, examples: Python, Lua, Node (Javascript) and PHP made by C Elixir by Erlang Nim by Pascal and so on... They all are string parsers that compile or interpret to a lower level language
Konstantin
almost all about classes, constructor, destructor, Python-style "this", Declaration and implementation..
Peter
guys, suppose I have a C program in C named my_program, echo "some text" | my_program how do I handle the piped input in my program... I've tried googling, but failed