#Include #Define Increment (X) ++X Int Main (Char PTR "Geeksquiz" Int X 10 Printf ("%S ", Increment (PTR) ) Printf ("%D", Increment (X) ) Return 0 )
#Include #Define Increment (X) ++X Int Main (Char PTR "Geeksquiz" Int X 10 Printf ("%S ", Increment (PTR) ) Printf ("%D", Increment (X) ) Return 0 )
#include <stdio.h>
#define INCREMENT(x) ++x
int main()
{
char *ptr = "GeeksQuiz";
int x = 10;
printf("%s ", INCREMENT(ptr));
printf("%d", INCREMENT(x));
return 0;
}
Answer:
-------------------------------------------------------------------------------------------------
2. What is output of below program?
#include <stdio.h>
#define merge(a, b) a##b
int main()
{
printf("%d ", merge(12, 34));
}
Answer:
-------------------------------------------------------------------------------------------------
3. What is output of below program?
#include <stdio.h>
#define get(a) #a
int main()
{
// GeeksQuiz is changed to "GeeksQuiz"
printf("%s", get(GeeksQuiz));
}
Answer:
Answer:
#include <stdio.h>
int main()
{
int x = 1;
switch (x)
{
x = x + 1;
case 1: printf("Choice is 1");
break;
case 2: printf("Choice is 2");
break;
default: printf("Choice other than 1 and 2");
break;
}
return 0;
}
Answer:
#include <stdio.h>
int main()
{
int x = 1;
switch (x)
{
case 2: printf("Choice is 1");
break;
case 1+1: printf("Choice is 2");
break;
}
return 0;
}
Answer:
Answer:
8. What is the difference between “const char* p” and “char const* p”?
int main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
}
Answer:
int main()
{
int x = 5;
int const * ptr = &x;
++(*ptr);
printf("%d", x);
return 0;
}
Answer:
int main()
{
int x = 5;
int * const ptr = &x;
++(*ptr);
printf("%d", x);
return 0;
}
Answer:
# include<stdio.h>
# include<stdlib.h>
void fun(int *a)
{
a = (int*)malloc(sizeof(int));
}
int main()
{
int *p;
fun(p);
*p = 6;
printf("%d\n",*p);
getchar();
return(0);
}
ANSWER:
# include <stdio.h>
int main()
{
char str1[] = "GeeksQuiz";
char str2[] = {'G', 'e', 'e', 'k', 's', 'Q', 'u', 'i',
'z'};
int n1 = sizeof(str1)/sizeof(str1[0]);
int n2 = sizeof(str2)/sizeof(str2[0]);
printf("n1 = %d, n2 = %d", n1, n2);
return 0;
}
ANSWER:
15. Given two strings like x=”hello” and y=”open”, remove any character from string x which is also
used in string y, thus making the result x=”hll”
Answer:
16. Write a program to find the number of times that a given word(i.e. a short string) occurs in a
sentence (i.e. a long string!). Read data from standard input. The first line is a single word, which is
followed by general text on the second line. Read both up to a newline character, and insert a
terminating null before processing.
Typical output should be:
17. Write a program to implement the single linked list as described list of interger. The program
consit of module below:
a. Create linked list
b. Delete a node that have key = x in linked list