C Questions
1.What is the output of this program?#include<stdio.h>
int main()
{
int a=10;
int b=++a;
printf("a=%d\nb=%d",a,b);
b=a++;
}
2. What is the output??
#include<stdio.h>
int main()
{
int a=10;
a+=15;
printf("%d",a);
}
3.print the array of elements 30 ,40 as a output ?
#include<stdio.h>
int main()
{
int a[7]={10,29,49,30,40};
}
int main()
{
int a[7]={10,29,49,30,40};
}
6 Comments
a=12 b=11
a=12 b=11
in this we have two types: 1:pre-increment(++a)
2:post-increment(a++)
Now Lets see example:
#include
int main()
{
int a=10;
int b=++a;
printf("a=%d\nb=%d",a,b);
}
in this code 1st variable a will be incremented after that value will assigned to b.
so output is:a=11
b=11
#include
int main()
{
int a=10;
b=a++;
printf("a=%d\nb=%d",a,b);
}
in this code 1st variable a will be assigned to variable b after that variable a will be increment.
output is: a=11
b=10