Have a look at the following piece of code and state and explain the output. #include int main() { // your code goes here int a = 10, b = 20; int *p = &a; *p = b; printf("%d", a); return 0; } ii) Have a look at the following piece of code and state and explain the output. #include void fun(int *a, int *b){ a = b; b = a; } int main(void) { // your code goes here int a = 10, b = 20; fun(&a, &b); printf("a: %d\n", a); printf("b: %d\n", b); return 0; } iii) Have a look at the following piece of code and state and explain the output. #include int main() { // your code goes here char s[20] = "abc"; if(strcmp(strcpy(s, "def"), "abcdef")) printf("Hi"); else printf("Bye"); return 0; }
i) Have a look at the following piece of code and state and explain the output.
#include <stdio.h>
int main() {
// your code goes here
int a = 10, b = 20;
int *p = &a;
*p = b;
printf("%d", a);
return 0;
}
ii) Have a look at the following piece of code and state and explain the output.
#include <stdio.h>
void fun(int *a, int *b){
a = b;
b = a;
}
int main(void) {
// your code goes here
int a = 10, b = 20;
fun(&a, &b);
printf("a: %d\n", a);
printf("b: %d\n", b);
return 0;
}
iii) Have a look at the following piece of code and state and explain the output.
#include <stdio.h>
int main() {
// your code goes here
char s[20] = "abc";
if(strcmp(strcpy(s, "def"), "abcdef"))
printf("Hi");
else
printf("Bye");
return 0;
}
iv) Have a look at the following piece of code and state and explain the output.
#include <stdio.h>
int main() {
// your code goes here
char s[20] = "abcdef";
strcpy(s, "\0");
printf("%d", strlen(s));
return 0;
}
v) Have a look at the following piece of code and state and explain the output.
#include <stdio.h>
int main() {
// your code goes here
char *s = "abcdef";
*(s + 2) = '\0';
printf("%d", s);
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images