[spoiler]
Code: Select all
#define size 10Code: Select all
c += 1;I express myself like an ***. I meant the 2 first numbers that are multiple of 3.Wdingdong wrote:I didn't understand this: "2 first multiple of 3 numbers."
Code: Select all
#define size 10Code: Select all
c += 1;I express myself like an ***. I meant the 2 first numbers that are multiple of 3.Wdingdong wrote:I didn't understand this: "2 first multiple of 3 numbers."

Hehe, So stupid of mem0skit0 wrote:And why not c++
OkWdingdong wrote:Ascending sorting
Why you keep comparing characters when you already know they are not equal? Waste of processing time.Wdingdong wrote:Check Equal Strings(Case Sensitive)
Same as previous one and also:Wdingdong wrote:Check Equal Strings(Not Case Sensitive)
Code: Select all
if(s1[i] > s2[i] && s1[i] - 32 != s2[i]) //The difference between value of upper and lower case is 32
count++;
else if(s2[i] > s1[i] && s2[i] - 32 != s1[i])
count++;There's no such exercise... You probably meant the 2 first multiples of 3. Anyway, you keep reading the array even if you don't need to (same error as 2 previous exercises).Wdingdong wrote:Three First Multiple of 3
OkWdingdong wrote:Matrix Addition
What's the problem?Wdingdong wrote:I'm stuck with checking the substring. It'd be good if you help a little

[spoiler]m0skit0 wrote: [*]Write a program that given an array of 10 numbers, prints only the even numbers.
Code: Select all
#include <stdio.h>
#define ARRAY_SIZE 10
main()
{
int array[ARRAY_SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int a;
for (a = 0; a <= 9; a++)
{
if (array[a] % 2 == 0)
printf("%d\n", array[a]);
}
} [spoiler][*]Write a program that given an array of 10 numbers, prints only the odd positions.
Code: Select all
#include <stdio.h>
#define ARRAY_SIZE 10
main()
{
int array[ARRAY_SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int a;
for (a = 0; a <= 9; a++)
{
if (array[a] % 2 == 1)
printf("[%d] ", a+1);
}
printf("\n");
} [spoiler][*]Write a program that given an array of 10 numbers, prints only the 2 first multiple of 3 numbers.
Code: Select all
#include <stdio.h>
#define ARRAY_SIZE 10
main()
{
int array[ARRAY_SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int a, b;
a = 0;
b = 0;
while (b < 2)
{
if (array[a] % 3 == 0)
{
printf("%d\n", array[a]);
b++;
}
a++;
}
}[spoiler][*]Write a program that given one string, prints its length.
Code: Select all
#include <stdio.h>
#define ARRAY_SIZE 10
main()
{
int a;
while (getchar() != EOF)
a++;
printf("%d", a);
}Code: Select all
main()Code: Select all
if (array[a] % 2 == 0)
printf("%d\n", array[a]);Code: Select all
for (a = 0; a <= 9; a++)You understood bad the goal of this exercise. You have to print the values of the array that are in odd positions, taking position in the array like 1st element (odd) is index 0, 2nd element (even) is index 1, and so on.0xB16B00B5 wrote:Write a program that given an array of 10 numbers, prints only the odd positions.
It does not. I'm a programmer, dude0xB16B00B5 wrote:Oh, and if the "a+1" looks weird, I'm just expirementing with stuff.
0xB16B00B5 wrote:I don't know (I have a horrible memory so sorry if you've already covered that) how to actually print the position from the array.
I don't see that much creativity, but only the best way to do it. Congrats!0xB16B00B5 wrote:Tried getting a bit creative for this one.
Not really, although your code is OK. Take this skeleton and try to complete it to do what's asked:0xB16B00B5 wrote:Not sure if that's what you wanted.. correct me if I'm wrong.
Code: Select all
#include <stdio.h>
int main()
{
char* target = "This is the string you have to calculate its length";
int length = 0;
// Put your code here!
print("The length of the target string is %d\n", length);
return 0;
}Code: Select all
while (getchar() != EOF)
a++;

Is this okay?m0skit0 wrote:Why you keep comparing characters when you already know they are not equal? Waste of processing time.
No, it's not. It's worse than before because this has several bugs:Wdingdong wrote:Is this okay?
