#16 Explain Array with example and declare int array | Need of Array | Assign values to Array | Code

preview_player
Показать описание
we will learn how to #create #array in #c++ in #hindi , what are arrays in programming, how to make array, declare int array, concept of array, and the meaning of array with examples
declare int array
one dimensional array example program
simple array example
need of array
assign values to array
array code example
int array values
array elements are stored in
array declaration
how to initialize array in c
integer array
array meaning in programming
what is array initialization
array representation in memory
array values
simple array program in c language
in array
array simple program
what is an array in program

-~-~~-~~~-~~-~-
Please watch: "Best Quotation Websites"
-~-~~-~~~-~~-~-
Рекомендации по теме
Комментарии
Автор

Aoa, sir ap ny bht achy sy explain kiya, mjy achi trah sy smj a gya, so plz nxt lec b aisy e smjaty rhye, thnku

alihasan
Автор

Q#4:find even index of 5given array no.
#incl // // //
Usin// / / /;
Int main (){
Int A[5]={2, 5, 8, 12, 9};
For (int i=0 ; i<5 ; i=i+2)
{
cout<<A[i];
}
Return 0;
}

ayatdkhan
Автор

// SOlution to Question No. 2
#include <iostream>
using namespace std;
int main() {
int arr[5];

for (int i =0; i<5; i++)
{

cout << "Enter the Elements " << i+1 << " = " ;
cin >> arr[i];
}


for (int i= 4; i>=0; i--)

{
cout << " "<<arr[i]<< " " << endl ;
}

cout << " : is the Reverse Array " ;

return 0;
}

muhammadzulqarnain
Автор

questionn#2
//input 5 numbers in array then display the number in reverse order
#include<iostream>
using namespace std;
int main()
{
int arr[5], i;
for(i=0;i<5;i++)
{
cout<<"enter the integer value"<<endl;
cin>>arr[i];

}
cout<<"number in actual order"<<endl;
for(i=0;i<5;i++)
cout<<arr[i]<<endl;
cout<<"number in reverse order"<<endl;
for(i=4;i>=0;i--)
cout<<arr[i]<<endl;
return 0;
}

tubashahzad
Автор

Assignment Solution all questions

Q1
#include<iostream>
using namespace std;
int main()
{
int sum =0;
int product =1;
float avg ;
int n[5];
for (int i=0; i<5; i++)
{
cout<< "enter five number" <<endl;
cin >>n[i];
}
int number;
cout <<" press 1 for sum" <<endl;
cout <<" press 2 for product " <<endl;
cout <<" press 3 for average" <<endl;
cin>> number;
if ( number ==1)
{
for (int i=0; i<5; i++)
sum =sum +n[i];
cout<<sum;
}
else
if (number==2)
{
for (int i=0; i<5; i++)
product= product* n[i];
cout <<product;
}
else
if (number ==3)
{
for (int i=0; i<5; i++)
sum =sum +n[i];
cout<<" sum is ="<<sum<<endl;
avg = sum /5;
cout <<" average is ="<<avg<<endl;
}
else
cout<<"invalid"<<endl;
}



Q2
#include<iostream>
using namespace std;
int main()
{
int n[5];
for (int i=1; i<=5; i++)
cin >>n[i];
for (int i=5; i>0; i--)
{
cout<<n[i]<<endl;
}

}



Q3
#include<iostream>
using namespace std;
int main()
{
int n[4];
int i;
int no=0;
for (int i=0; i<4; i++)
{
cout <<"enter 4 number" <<endl;
cin>>n[i];
}
no =0;
no = n[0];
n[0]=n[3];
n[3]=no;
cout <<"after swap first number is ="<<n[0]<<endl;

}
Q4
#include<iostream>
using namespace std;
int main()
{
int n[5];
n[5]= 2; 5; 8; 12; 9;
if (n[5] %2 ==0 )
{
cout <<"Even number is="<<n[5]<<endl;
}
else
cout<<" odd"<<endl;

}

umme__aina
Автор

i like your lectures
sir app buht acha knowledge provide krty hein buht koch sekhne ko milta ha app ke lectures se

Painty
Автор

//Question no 3:

#include<iostream>
using namespace std;

int main(){
int num[5];
cout << "Enter numbers " <<endl;
for(int i=0;i<5;i++)
{
cin >> num[i];
}
int temp=num[4];
num[4]=num[0];
num[0]=temp;
cout << "After swaping numbers are"<<endl ;
for(int j=0;j<5;j++)
{cout<<num[j]<<endl;
}
return 0;
}

hammadbhai
Автор

Bhai bht ache way se smjhate hain ap👌👌

SameerAli-doxc
Автор

good teaching method.
thank you
by
(must mirpur)

sajidali-qbko
Автор

Q3:
#include <iostream>
using namespace std;
int main()
{
int display[4];
int temp;
for(int i=0; i<4; i++)
{
cout<<"enter the number :"<<endl;
cin>>display[i];
}
temp=display[0];
display[0]=display[3];
display[3]=temp;
cout<<"value of "<<display[0]<<" after reversing is:"<<display[3]<<endl;
cout<<"value of "<<display[3]<<" after reversing is:"<<display[0]<<endl;
return 0;
}
Q2:#include <iostream>
using namespace std;
int main()
{
int res;
int display[5];
for(int i=1; i<=5; i++)
{
cout<<"enter the number"<<endl;
cin>>display[i];
}
cout<<"the reverse order is"<<endl;
for(int i=5; i>0; i--)
{
cout<<display[i]<<endl;
}

}
Not a good approach, but an approach.
Q4;
#include <iostream>
using namespace std;
int main()
{
int display[5]={2, 5, 8, 12, 9};
int n;
n=display[5];
if(display[0]%2==0)
cout<<"the even number is :"<<display[0]<<endl;
if(display[1]%2==0)
cout<<"the even number is :"<<display[1]<<endl;
if(display[2]%2==0)
cout<<"the even number is :"<<display[2]<<endl;
if(display[3]%2==0)
cout<<"the even number is :"<<display[3]<<endl;
if(display[4]%2==0)
cout<<"the even number is :"<<display[4]<<endl;
return 0;
}

anchi
Автор

//Solution to Question NO. 1

#include <iostream>
using namespace std;
int main()
{
int num [5];

for (int i=0; i<5; i++)

{

cout << "enter numbers : " << endl;
cin >> num[i];
}
int menu;
cout << "Press 1 for Sum" << endl;
cout << "Press 2 for Product" << endl;
cout << "Press 3 for Average" << endl;
cin>> menu;



if (menu == 1)
{
int sum=0;
for (int i=0; i<5; i++)
sum = sum+ num[i];

cout << "The Sum is " << sum << endl;
}
else if (menu == 2)
{
int pro = 1;
for (int i =1; i<5; i++)
pro = pro * num[i];
cout << "The Product : " << pro << endl;
}
else if (menu == 3)
{
int avr=0;
int sum=0;
for (int i =0; i<5; i++)
sum = sum + num[i];

cout << "The Average is : " << sum / 5 << endl;
}

else
{
cout << "invalid statement";
}





return 0;
}

muhammadzulqarnain
Автор

Q#2:
#include<iostream>
using namespace std;
int main(){
int a[5];
cout<<"Enter five numbers: "<<endl;
for(int i=0; i<=4; i++){
cin>>a[i];
}
cout<<"After reversing: "<<endl;
for(int i=4; i>=0; i--){
cout<<a[i]<<endl;
}
}

rimshamalikmalik-io
Автор

Q#3:
#include<iostream>
using namespace std;
int main(){
int n[4], temp;
cout << "Enter numbers " <<endl;
for(int i=0;i<4;i++){
cin >> n[i];
}
temp=n[3];
n[3]=n[0];
n[0]=temp;
cout << "After swaping numbers are"<<endl ;
for(int j=0;j<4;j++){
cout<<n[j]<<endl;
}
}

rimshamalikmalik-io
Автор

Q#4:
#include<iostream>
using namespace std;
int main(){
int a[5]={2, 5, 8, 9, 12};
cout<<"Even numbers= "<<endl;
for( int i=0; i<=4; i++){
if(a[i]%2==0)
cout<<a[i]<<endl;
}
}

rimshamalikmalik-io
Автор

int arr[5];
cout << "Put the numbers are in arrays are" << endl;
for (int i = 0; i < 5; i++)
{
cin >> arr[i];
}
cout << "the orignal numbers of arrays is" << endl;
for (int i = 0; i < 5; i++)
{
cout<< arr[i];
}

for (int i = 4; i >=0; i--)
{
cout<<arr[i];
cout<<endl;
}

abdulmalikkhan
Автор

Nice srr app abhi bhi koibgroup bnaya hua jha programing exercise krwaty haii

shumailaazhar
Автор

Sr ap array used as. A function or parameter kesy pass krty hn us py b vedio bna dy

moonashazadi
Автор

Your way of teaching is too good.
But i have some queries reagarding functions. Can you help me...

usmansajid
Автор

ap please koi arrays per aik lec bana k yahan pr hi link description main day dain

kamranmeerawan
Автор

great explaination sir.
quetion 4 answer:


#include <iostream>

using namespace std;

int main()
{
int a[5]={1, 2, 3, 4, 5};
int i;
int sd=sizeof(a)/sizeof(a[0]);
cout<<"sd is :"<<sd<<endl;
/// int ele=sd%2==0;
for(i=0;i<sd;i++)
{
if(i%2!=0)
{
cout<<"index of even number"<<a[i]<<endl;
}
}

return 0;
}

kirantak