i)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;}iv)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] = "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 int main() { // your code goes here char *s = "abcdef"; *(s + 2) = '\0'; printf("%d", s); return 0;}
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;}iv)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] = "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 int main() { // your code goes here char *s = "abcdef"; *(s + 2) = '\0'; printf("%d", s); return 0;}
void fun(int *a, int *b){
a = b;
b = a;
int main(void) {
fun(&a, &b);
printf("a: %d\n", a);
printf("b: %d\n", b);
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;}iv)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] = "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 int main() { // your code goes here char *s = "abcdef"; *(s + 2) = '\0'; printf("%d", s); return 0;}
char s[20] = "abc";
if(strcmp(strcpy(s, "def"), "abcdef"))
printf("Hi");
else
printf("Bye");
iv)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] = "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 int main() { // your code goes here char *s = "abcdef"; *(s + 2) = '\0'; printf("%d", s); return 0;}
char s[20] = "abcdef";
strcpy(s, "\0");
printf("%d", strlen(s));
v)Have a look at the following piece of code and state and explain the output.
#include int main() { // your code goes here char *s = "abcdef"; *(s + 2) = '\0'; printf("%d", s); return 0;}
char *s = "abcdef";
*(s + 2) = '\0';
printf("%d", s);
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here