Question 11
void myStrcat(char *a, char *b)
{
int m = strlen(a);
int n = strlen(b);
int i;
for (i = 0; i <= n; i++)
a[m+i] = b[i];
}
int main()
{
char *str1 = \"Geeks \";
char *str2 = \"Quiz\";
myStrcat(str1, str2);
printf(\"%s \", str1);
return 0;
}
Question 12
#include <stdio.h>
#include <stdarg.h>
int fun(int n, ...)
{
int i, j = 1, val = 0;
va_list p;
va_start(p, n);
for (; j < n; ++j)
{
i = va_arg(p, int);
val += i;
}
va_end(p);
return val;
}
int main()
{
printf(\"%d\\n\", fun(4, 1, 2, 3));
return 0;
}
Question 13
#include \"stdio.h\"
int main()
{
int a = 10;
int b = 15;
printf(\"=%d\",(a+1),(b=a+2));
printf(\" %d=\",b);
return 0;
}
Question 14
unsigned long int
type length is 64 bits.
unsigned long int fun(unsigned long int n) {
unsigned long int i, j = 0, sum = 0;
for( i = n; i > 1; i = i/2) j++;
for( ; j > 1; j = j/2) sum++;
return sum;
}
fun
with the input 240 is
Question 15
#include <stdio.h>
void fun1(char *s1, char *s2) {
char *temp;
temp = s1;
s1 = s2;
s2 = temp;
}
void fun2(char **s1, char **s2) {
char *temp;
temp = *s1;
*s1 = *s2;
*s2 = temp;
}
int main() {
char *str1 = \"Hi\", *str2 = \"Bye\";
fun1(str1, str2);
printf(\"%s %s\", str1, str2);
fun2(&str1, &str2);
printf(\"%s %s\", str1, str2);
return 0;
}
Question 16
Question 17
What will be the output of the following ‘C’ code?
#include <stdio.h>
int main()
{
int x = 128;
printf("\n%d", 1 + x++);
return 0;
}
Question 19
int tob (int b, int* arr) {
int i;
for (i = 0; b>0; i++) {
if (b%2) arr [i] = 1;
else arr[i] = 0;
b = b/2;
}
return (i);
}
int pp(int a, int b) {
int arr[20];
int i, tot = 1, ex, len;
ex = a;
len = tob(b, arr);
for (i=0; i<len ; i++) {
if (arr[i] ==1)
tot = tot * ex;
ex= ex*ex;
}
return (tot) ;
}
Question 20
Consider the following C program.
#include <stdio.h>
int main()
{
int i, j, count;
count = 0;
i = 0;
for (j = -3; j <= 3; j++)
{
if ((j >= 0) && (i++))
{
count = count + j;
}
}
count = count + i;
printf("%d", count);
return 0;
}
Which one of the following options is correct?
There are 37 questions to complete.