do-while Loop In C Programming Language

preview_player
Показать описание

In this video tutorial lets learn about the general syntax and working of do-while loop in C programming language.

Note: Since we might start to input information from the keyboard repeatedly inside do-while block, scanf() method keeps checking the input buffer. And often times it gets confused with the input buffer and thinks that the user has pressed the enter key. To avoid that we flush out the previous buffer present in input device(ex: keyboard) using function fflush(). fflush takes stdin as argument, so that it can clear the buffer of standard input device. fflush(stdin);

C Programming Interview / Viva Q&A List

C Programming: Beginner To Advance To Expert
Рекомендации по теме
Комментарии
Автор

Love your videos it has helped me a lot in my coding subjects

vestedits
Автор

Thank you sir, good and clear explanation

khairulnizam
Автор

Really really thank you!!!dude I spent a night to understand this loop, but still not get it, but after your video, I understand more!! Thanks buddy😭😭

zhangjiahao
Автор

Because of this I could use y/n in do while loop.or else their was the same error, thanks man👍

asitanand
Автор

can you do it with a basic calculator?

jasoncuajao
Автор

mine stops at (y/n) and when i enter y it says dash 2 y not found

taylorbatumbakal
Автор

if I want to input Y or y for continue, it’s will be like this?
}while(C == ‘y’ || C == ‘Y’);
anybody answer me, plz.

Grandpa_John
Автор

Design an algorithm to accept an array of 5 positive integers.
The algorithm must then find the smallest positive integer in the array which cannot be formed from
the sum of 2 numbers in the array.

For Example –
If the input elements are:
5, 3, 2, 6, and 4

Method 1 (look at different methods to solve):
6 can be formed by 2 + 4 (both elements from the array)
5 can be formed by 3 +2 (both elements from the array)
4 cannot be formed by adding 2 elements in the array
3 cannot be formed by adding 2 elements in the array
2 cannot be formed by adding 2 elements in the array

The answer is 2 because it is the smallest integer which cannot be formed.

praveenkumar-wvxn
Автор

#include<stdio.h>
int main()
{
int a, b, c;
char ch;
do
{
printf("Enter the 1st No.");
scanf("%d", &a);
printf("Enter the 2nd No.");
scanf("%d", &b);
c=a+b;
printf("\nSum is =%d", c);
printf("\nAre you want to continue(y/n)");
scanf("%c", &ch);
fflush(stdin);
}while(ch=='y');
}

My code is not continue. Where is the problem sir?

rajadasgupta
visit shbcf.ru