Harmanjit
God bles u
Dima
Dima
no photos of a screen
Dima
Harmanjit
Sorry, but how will i ask that what fault i am at
Dima
Use pastebin or hastebin services
Dima
or if your code is short, post it here using Monospace style
Dima
Because it’s so hard to read your screen photo, which also is rotated
Harmanjit
I will search about pastepin or hastebin n monospace, i hv no idea , i m a beginner
Harmanjit
Wil try not to post photo
Harmanjit
#include <stdio.h>
void main()
{
int salary, sum=0, deduction=0, month=1, i=1;
printf("Enter your salary from January (01) to December(12) to find our annual salary and deductions\n");
do
{
printf("Enter your salary of month %d: ",month);
month++;
scanf("%d",&salary);
sum=sum+salary;
deduction=deduction+(15000-salary);
i++;
}
while(i<=12);
printf("\nTotal salary is %d",sum);
printf("\nTotal deduction is %d",deduction);
return 0;
}
I_Interface
Harmanjit
👌ok bro
Harmanjit
Wap using switch to find even odd vowel constant? Using switch and do while loop.
I will try to solve in 10 or 15 mins n plz than help me to find my mistakes.
Anonymous
Explain malloc()
Sandy
I am beginner to c++ so please tell me how to learn
I_Interface
Explain malloc()
int* ptr = malloc(10 * sizeof(int));
creating array of int digits for 10 elements
I_Interface
for example
I_Interface
malloc returns a pointer from where it allocated a memory
I_Interface
Explain malloc()
But ofc u can google it and read, don't forget it
I_Interface
Anonymous
I_Interface
Okay
Do u understand what i explain to u ?
I_Interface
about malloc
Anonymous
about malloc
Ya little bit,,,,but why we use malloc()
Anonymous
I_Interface
Anonymous
Harmanjit
Wap using switch to find even odd vowel constant? Using switch and do while loop.
Harmanjit
#include <stdio.h>
#include <stdlib.h>
void main()
{
int odd, even, constant, vowel, num, oecw;
char c;
do { printf("1.To find no is even or odd :");
printf("2.To find alphabet is constant or vowel :");
printf("3.Exit.");
scanf("%d",&oecw)
switch(oecw)
case 1:
{printf("Enter your number :");
scanf("%d",num)
}
if(0=num/2)
{printf("Number is even");}
else {printf("Number is odd");}
break;
case 2:
{printf("Enter alphabet :");
scanf("%d",num)
}
if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U'||c=='a'||c=='e'||c=='i'||c=='o'||c=='u');
{printf("Vowel");}
else {printf("Constant");}
break;
} while
Harmanjit
Help
Harmanjit
@Remavas @bi_kash
I_Interface
What the Hell
Anonymous
Explain malloc()
malloc(): This function is used to allocate memory dynamically.
This allocates memory during runtime.
Imagine a situation where you want to calculate the sum of 'n' numbers and you
declare an array for it. 'n' can be any number that user will enter.
eg: int arr[100];
now when you ask the user to enter the value of n and the user enter say for eg: 20
in that case you waste (100-20) = 80 locations which is 80 * 4 bytes assuming sizeof(int) is 4 bytes
wouldn't it be nice if there was some way to declare variable after user entered the value of 'n'
This shortcoming is handled by malloc()
eg: int n;
printf("Enter n?\n");
scanf("%d",&n);
int *arr = (int *) malloc(n*sizeof(int)); // memory is allocated on demand and you've have to delete after you are done with the memory.
I_Interface
I_Interface
Anonymous
Hi Hi Hi~
Anonymous
Anonymous
Hi
Anonymous
Anyone have telegram channel?
I_Interface
Anonymous
I_Interface
Who?
Ask only about C/C++ questions
I_Interface
Anonymous
Dima
What it supposed to mean lol!
Anonymous
Anonymous
I just know the basic of c
Anonymous
Not other things
Kwame
Hello guys
Kwame
Please I need a link to C# tutorial channel
Kwame
Can someone help me out
Kwame
?
Kwame
Seen
Anonymous
Does std::map<T1,T2> take 0(log(n)) time complexity for finding the value of a key?
where n is the no. of keys stored in the map.
cout<<mp[5];
Anonymous
#ot go there
Anonymous
Anonymous
Anonymous
more people will get to know this. That's the point
Anonymous
And read the rules again, the second one. Asking questions that can be easily googled is not good here.
Anonymous
Thnku
Anonymous
Will (int)ceil((double)an_int_no./(double)another_int_no.)) give me the right result of a ceiling of 2 integers?
Anonymous
in all cases?
Anonymous
Anonymous
ceil of a/b
Anonymous
It will ceil the result of a/b
Anonymous
And then cast to int
Anonymous
I mean a/b will be int. I don't want that
Anonymous
Anonymous
yep
Anonymous
I'm asking if that will work?
Anonymous
So what's the problem?
Anonymous
Anonymous
Anonymous
The result of the whole expression will be double
Anonymous
If you casted one or both of the operands