1.
What will be output of the following C code where we copy an array ‘a’ into array ‘b’ and then
the array ‘b’ into ‘a’?
#include<stdio.h>
#include<string.h>
main()
char a[] = "hell";
char b[] = "hello";
strcpy(b, a);
strcpy(a, b);
printf("%s, %s", a, b);
2. Predict the Output
#include <stdio.h>
int main() {
char *str = "hello";
str[0] = 'H';
printf("%s", str);
return 0;
What will be the output?
3. Identify the Output
#include <stdio.h>
int main() {
int arr[] = {10, 20, 30, 40, 50};
printf("%d", 2[arr]);
return 0;
What will be the output?
4. Predict the Output
#include <stdio.h>
#include <string.h>
int main() {
char str1[] = "hello";
char str2[] = "hello";
if (str1 == str2)
printf("Equal");
else
printf("Not Equal");
return 0;
What will be the output?
5. Predict the Output (sizeof with String Literal)
#include <stdio.h>
int main() {
printf("%lu", sizeof("abc"));
return 0;
What is the output?
6. Predict the array with 2D Array Access
#include <stdio.h>
int main() {
int arr[2][2] = {{1, 2}, {3, 4}};
printf("%d", *(*arr + 3));
return 0;
What will be the output?
7. Predict the output
#include <stdio.h>
int main() {
char str[] = {'H', 'e', 'l', 'l', 'o', '\0'};
printf("%c", str[5]);
return 0;
What is the output?
8. Predict the output
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "abc";
printf("%lu %lu", sizeof(str), strlen(str));
return 0;
9. Predict the output
#include <stdio.h>
int main() {
char *str[] = {"Hello", "World"};
printf("%c", *(*(str+1)+1));
return 0;
10.Predict the output:
#include <stdio.h>
int main() {
char *msg[] = {"Hi", "There", "Coder"};
char **p = msg;
p++;
printf("%c\n", *(*(p) + 2));
return 0;
11.Predict the output:
#include <stdio.h>
int main() {
char *nums[] = {"One", "Two", "Three"};
char **p = nums + 1;
printf("%c\n", *(*p + 2));
return 0;
12. Predict the Output (Reverse Access)
#include <stdio.h>
int main() {
char *fruits[] = {"Apple", "Banana", "Mango"};
printf("%c\n", fruits[2][-2]);
return 0;
13. Predict the Output (Character Skipping)
#include <stdio.h>
int main() {
char *langs[] = {"C", "Python", "Java"};
printf("%s\n", langs[1] + 2);
return 0;