C Programming Interview Questions and Answers-7
Q: – Write a program to reverse a string with out using any array? #include<stdio.h> int main() { char *str=”Mahesh”; char *ptr=str+strlen(str); while(ptr>=str) { printf(“%c”,*ptr); ptr–; } } Q: – How do you find IP adress of ur system? ipconfig – in windows cmd mode. ifconfig -a in linux and hostname|nslookup in linux. Q: – What is the output of this program? #include<stdio.h> void Allocate(char *str, int size) { str =(char *)malloc(size); } int main() { char *str; Allocate(str, 20); strcpy(str, “HCL”); strcat(str, “Technologies”); printf(“%sn”,str); } Answer:Run time error(segmentation fault). Reason: in function Allocate, we have allocated memory by using … Click here to continue reading.