Quick links: HR Interview Que. Code Snippets C Programs C++ Programs Java Programs Scala Solved Examples PHP Examples

Home » C programming language

Find output of C programs Questions with Answers (Set - 2)

Question - 1

#include <stdio.h>
int main()
{
	int x;
	x = 10;
	
	if(x > 10)
		x -= 10;
	else if(x >= 0)
		x += 00;
	else if(x)
		x += 10;
	else
		x -= 10;
	
	printf("%d\n",x);
	return 0;
}

Output

10

Sponsored Links

Question - 2

#include <stdio.h>
int main()
{
	int a = -10, b = 20;
	
	if(a > 0 && b < 0)
		a++;
	else if(a < 0 && b < 0)
		a--;
	else if(a < 0 && b > 0)
		b--;
	else
		b--;
	
	printf("%d\n",a + b);
	return 0;
}

Output

9

Question - 3

#include <stdio.h>
int main() 
{
	int a= -1,b = -a;
	int x,y;
	
	x = (a> 0) && (b < 0) || (a< 0) && (b > 0);
	y = (a<= 0) || (b >= 0) && (a>= 0) || (b <= 0);
	
	printf("%d\n",x == y);
	
	return 0;
}

Output

1

Question - 4

#include <stdio.h>
int main()
{
	int a=10,b=20,*p,s=0;
	
	p = &a;
	a++;
	(*p)++;
	s = a + b + *p;
	
	printf("%d\n",s);
	return 0;
}

Output

44

Question - 5

#include <stdio.h>
#include <string.h>
int main() 
{
	char str[20] = "ABCDEFGHIJK";
	int s = strlen(str);
	
	str[3] = '\0';
	s = strlen(str);
	
	printf("%d\n",s);
	return 0;
}

Output

3

Question - 6

#include <stdio.h>
#include <string.h>
int main()
{
	char str[20] = "ABCDEFGHIJK";
	int s = strlen(str);
	
	str[3] = '\0';
	s += strlen(str);
	strcpy(str,"ABCDEF");
	s += strlen(str);
	strcat(str,"ABC");
	s += strlen(str);
	
	printf("%d\n",s);
	return 0;
}

Output

29

ANY DOUBT? WRITE HERE...

Keywords (like Linux, Java, Oracle etc) used in this website are the trademarks of their respective owners/company. This website is not affiliated to any company. The tutorials are designed by includehelp Team with the help of well known books and other online resources. These Tutorials are free for all, for learning purposes only. Enjoy learning:)
Copyright © 2015 - 2016. All Rights Reserved.