Skip to main content

Featured

Awesome Python Turtle

Awesome Pythhon Turtle Colour Changing Vibrant Circle in Python import turtle tur=turtle.Turtle() scr=turtle.Screen() scr.bgcolor('black') tur.pencolor('white') x=0 y=0 tur.speed(0) tur.penup() tur.pendown() colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow'] while True: tur.pencolor(colors[y%6]) tur.forward(x) tur.right(y) x +=3 y +=1 if y==210: break tur.hideturtle() turtle.done() Output:

Arrays Programs in C++

                                    Arrays Program

Q: Write a program to store 5 numbers enter by users in an array and display first and last number only

#include<iostream>
using namespace std;

int main(){

int n =5;
int array[n];
cout<<"Enter the Values\n";
//Enters the Values in an Array
for(int i=0 ; i<n ; i++){
cin>>array[i];
}
cout<<"First number in an array is "<<array[0]<<endl;
cout<<"Last number in an array is "<<array[n-1]<<endl;
return 0;
}


Output:


Q: Write a program that lets the user enter 10 values into an array. The program should display largest and smallest values stored in the array 

#include<iostream>

using namespace std;

int main(){

int array[10];
cout<<"Enter the values in an array\n";
for(int i=0 ; i<10 ; i++){
cin>>array[i];
}
int min=array[0];
for(int i=0 ; i<10 ; i++){
if(array[i]<min){
min = array[i];
}
}
cout<<"Smallest value in array is "<<min<<endl;
int max=array[0];
for(int i=0 ; i<10 ; i++){
if(array[i]>max){
max = array[i];
}
}
cout<<"Largest value in array is "<<max<<endl;

}

Output:

Comments

Popular Posts