I thought you want us to learn it by ourselves. So,I've gained some basic knowledge about it. But, whatever I know, I lay no claim on it, it's all because of you and this forumm0skit0 wrote:Well I see you already know functions and flow control, that's niceAlthough I will recover this exercises soon enough
Here are my exercise answers:
[spoiler]
Code: Select all
#include <stdio.h>
#include <stdlib.h>
void exercise1And2() //first and second exercise combined
{
int* a = malloc(50*sizeof(int));
*(a+4) = 1;
*(a+5) = 2;
*(a+7) = 3;
printf("%d %d %d\n",*(a+4),*(a+5),*(a+7));
}
void exercise3() //Using only pointers: given a random string, print from the 5th character onwards.
{
char* s2 = "Not galaxy s2";
printf("%s\n",(s2+4));
}//Is it this much only?
void exercise4() //XOR operation
{
char s[5] = "Uncle";
char s1[5] = "Jessy";
int a = s[0] ^ s1[0];
int b = s[1] ^ s1[1];
int c = s[2] ^ s1[2];
int d = s[3] ^ s1[3];
int e = s[4] ^ s1[4];
printf("%d %d %d %d %d",a,b,c,d,e);
}
int main()
{
exercise1And2();
exercise3();
exercise4();
return 0;
}
Corrections accepted





