Home » Aptitude Questions and Answers » C Aptitude Questions and Answers

C while loop Aptitude Questions and Answers



This section contains Aptitude Questions and Answers on C language while Loops (with multiple answers) with explanation.
Submitted by Ashish Varshney, on February 21, 2018

List of C programming for while Aptitude Questions and Answers

1) What will be the output in given input?

When, input: 'a' and 1

int main()
{
	int n,i=0;
	while(scanf("%d",&n)==1)
	{
		printf("END\n");
	}
	return 0;
}
  1. Runtime_error and Compile time error
  2. Compile time error and Runtime_error
  3. Syntax error and Syntax error
  4. No output and END

2) How many times above loop will execute?

int main()
{
	int n=10,i=0;
	while(1)
	{
		printf("END\n");
		n++;
	}
	return 0;
}
  1. 10
  2. 5
  3. 4
  4. Infinite

3) What is the value of 'n' after while loop executed?

int main()
{
	int n=0,a=5,b=10;
	while(n<=(a^b))
	{
		n++;
	}
	printf("%d",n);
	return 0;
}
  1. 15
  2. 16
  3. 10
  4. None of this.

4) What is the value of 'n' after while loop executed?

int main()
{
	int n=0,a=5,b=10;
	while(n<=(b<<a))
	{
		n++;
	}
	printf("%d",n);
}
  1. 64
  2. 256
  3. 321
  4. 320

5) What will be the output?

int main()
{
	int a=16,n=0;
	while(n<=~(~a))
	{
		n++;
	}
	a=n;
	printf("%d",~a);
	return 0;
}
  1. -18
  2. -17
  3. 18
  4. 17






Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.



Comments and Discussions





© https://www.includehelp.com (2015-2018), Some rights reserved.




Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.
Close