What will be the output of the following C++ code?
#include<stdio.h>
int main()
{
int i=12;
int j=sizeof(i++);
printf("%d %d",i,j);
return 0;
}
What is the name of the following operator?:
Now consider a slightly modified version of the previous question. Is it possible that function foo is called?
int x;
&x;
if (x != x) foo();
Predict the output of the following C program:
#include <stdio.h>
int main()
{
int a[] = {1, 2, 3, 4, 5, 6};
int *ptr = (int*)(a + 1);
printf("%d", *(ptr - 1));
return 0;
}
#include<stdio.h>
#include<stdarg.h>
int func(int count,...)
{
int val=0,i;
va_list p;
va_start(p,n,count);
for(int j=1;j<;j++)
{
i=va_arg(p,count);
val+=i;
}
va_end(p);
return val;
}
int main()
{
printf("%d",func(4,3,2,1));
return 0;
}
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
int x = -1;
unsigned int y = 2;
if(x > y)
{
cout << "x is greater";
}
else
{
cout << "y is greater";
}
}
#include <stdio.h>
#define SIZE(arr) sizeof(arr) / sizeof(*arr);
void fun(int* arr, int n)
{
int i;
*arr += *(arr + n - 1) += 10;
}
void printArr(int* arr, int n)
{
int i;
for(i = 0; i < n; ++i)
printf("%d ", arr[i]);
}
int main()
{
int arr[] = {10, 20, 30};
int size = SIZE(arr);
fun(arr, size);
printArr(arr, size);
return 0;
}
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class A{
public:
A(){
cout<<"Constructor called\n";
}
~A(){
cout<<"Destructor called\n";
}
};
int main(int argc, char const *argv[])
{
A *a = new A[5];
delete a;
return 0;
}
Consider the following C code:
#include <stdio.h> int * assignval (int *x, int val) { *x = val; return x; } int main() { int *x = malloc(sizeof(int)); if (NULL == x) return; x = assignval(x, 0); if(x) { x = (int*) malloc(sizeof (int)); if (NULL == x) return; x = assignval (x, 10); } printf("%dn", *x); free(x); }
The code suffers from which one of the following problems:
OnSite
1 Openings
FullTime
Posted 17 days ago