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






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.