Whenever the elements of both the arrays are equal just increment the value of flag from 0 and at last compare it with array size if both are equal then array is equal
@sannin98753 жыл бұрын
woow super ,excellent
@mahmoudelkhadragy81545 жыл бұрын
as i think break ; statement is not a good solution as it breaks the code suddenly and go out from the loop or if condition we can do that as an another solution int a[4] = { 2,5,7,4 }, b[4] = { 2,5,7,4 },i , flag1 = 0, flag2 = 0; for (i = 0; i < 4; i++) { if(a[i] == b[i]) { flag1 = 1; } else { flag2 = 1; } } if (flag1 == 1 && flag2 == 0) { printf("array a equal array b "); } else { printf("array a not equal array b "); }
@hassansyed56613 жыл бұрын
Break won't break the code. Think for a second if we are comparing a large array elements then it will waste a lot of CPU cycles which could be easily saved with the help of break statement.
@sarcaastech6 жыл бұрын
sir we can use break statement with and print that the array are not equal .... so whenever the comditions fail we will come out of loop flag=1 for(i=0;i
@33256312734 жыл бұрын
if they are equal then also it will show arrays are not equal
@pragyagupta77364 жыл бұрын
Use the printf statement properly coz in this code at the end it anyway prints arrays are not equal. Rest is fine...👍
@MEFRAJANS4 жыл бұрын
No bro. because once loop kum once statement print agum.
@hussainkhan-fg1lv4 жыл бұрын
@@pragyagupta7736 yes its out side the else block
@pragyagupta77364 жыл бұрын
@@hussainkhan-fg1lv yep🙂
@n.hemanthkumar16154 жыл бұрын
we can use int main() { int flag=1; for(i=0;i
@7cyuthika7512 жыл бұрын
CRT
@deependrasingh26363 жыл бұрын
Outstanding fantastic mind-blowing sir
@sandeeppateriya17655 жыл бұрын
Once we get flag= 0, we can use 'exit' to come out and hence our problem is solved..
@vinodkumarpvinod66793 жыл бұрын
Respected sir thanks for teaching us We are very proud to have such a professor India proud to be an indian sir
@bhargavdihora12454 жыл бұрын
We can define flag[4], in this case and put another for loop after this entire programme as follows for(i=0;i
@MEFRAJANS4 жыл бұрын
I think not possible
@hussainkhan-fg1lv4 жыл бұрын
This loop will be executed after the previous one so then loop will not change anything you will still have to deal with the problem My suggestion at 15:26 : just put a "exit" below "flag =0" And also add #include as "exit statement is a part of this library.
@rishabhgupta54606 жыл бұрын
Sir we can put a break statement with else condition.
@ritikpanwar89565 жыл бұрын
Yes you can
@hussainkhan-fg1lv4 жыл бұрын
Yes
@AshishKumar-zc5bc4 жыл бұрын
clear the concept of array
@srinidolic5 жыл бұрын
Sir could you please mention the function of "flag" variable in the problem stated and also please give applications of it too.
@jyotimanral29895 жыл бұрын
srinidolic flag is just a variable used in this problem to check whether the elements os the 2 arrays are comparable or not.It has no such application
@kangtheconqueror36392 жыл бұрын
program to compare two array #include int main() { int a[5],b[5],i,flag=1; printf("enter the first array "); for (i=0;i
@ChandanAkbarpuria3 жыл бұрын
Instead of flag =1(assignment) We can use 'continue' keyword
@sritamkunu91554 жыл бұрын
Just add a else if block if ..if blok will be false then else if blok will execute and from elseif blok we have to write logic to flag to again zero
@likithgullapudi22753 жыл бұрын
14:21 use another array for flag simple
@saikatchatterjee48696 жыл бұрын
can anybody send the slides of every week
@MdSahidReja196 ай бұрын
#include int main() { int a[]={2,5,7,4},b[]={2,5,6,4},i; int flag = 1; for( i=0; i
@pranavchaitu Жыл бұрын
#include int main() { int arr1[] = {1,3,2}; int arr2[] = {1,3,2}; int flag = 0; for(int i=0;i