Posts

Showing posts from November, 2022

Making list with Listview in flutter

  body : ListView . separated ( itemBuilder : ( context , index ) { return Text ( arrNames [ index ], style : TextStyle ( fontSize : 25 , fontWeight : FontWeight . w500 ), ); }, itemCount : arrNames . length , separatorBuilder : ( context , index ) { return Divider ( height : 50 , thickness : 6 , ); }, ));

creating scroll view horizontal and vertical in a container in flutter

  body : SingleChildScrollView ( child : Padding ( padding : const EdgeInsets . all ( 8.0 ), child : Column ( children : [ SingleChildScrollView ( scrollDirection : Axis . horizontal , child : Padding ( padding : const EdgeInsets . only ( bottom : 11 ), child : Padding ( padding : const EdgeInsets . all ( 8.0 ), child : Row ( children : [ Container ( margin : EdgeInsets . only ( right : 11 ), width : 200 , height : 200 , color : Colors . red , ), Container ( margin : EdgeInsets . only ( right : 11 ), width : 200 , height : 200 , ...

make any thing clickable example with container in flutter

  body : Center ( child : InkWell ( onTap : () { print ( 'clicked' ); }, onDoubleTap : () { print ( 'double tapped' ); }, onLongPress : () { print ( 'long pressed' ); }, child : Container ( height : 200 , width : 200 , color : Colors . red , ), ), ));

creating a background coloured box in flutter;

  body : Container ( padding : EdgeInsets . all ( 35 ), margin : EdgeInsets . all ( 20 ), decoration : BoxDecoration ( border : Border . all ( color : Colors . black , width : 4 ), borderRadius : BorderRadius . circular ( 8 ), boxShadow : [ new BoxShadow ( color : Colors . green , offset : new Offset ( 6.0 , 6.0 ), ), ], ), child : Text ( "Hello! I am Minhaj Raza and i want to become developer!!" , style : TextStyle ( fontSize : 30 )), ), );

creating buttons in flutter

import 'package:flutter/material.dart' ; void main () { runApp ( const MyApp ()); } class MyApp extends StatelessWidget { const MyApp ({ super . key }); // This widget is the root of your application. @ override Widget build ( BuildContext context ) { return MaterialApp ( title : 'Flutter Demo' , theme : ThemeData ( primarySwatch : Colors . blue , ), home : MyHomePage (), ); } } class MyHomePage extends StatelessWidget { @ override Widget build ( BuildContext context ) { return Scaffold ( appBar : AppBar ( title : Text ( 'My application' )), body : OutlinedButton ( child : Text ( 'click here !' ), onPressed : () { print ( 'Button is pressed' ); }, onLongPress : () { print ( 'long pressed!' ); }, )); } }  

program to sort an array

#include <iostream> using namespace std ; // funtion to sort the array void sortingarr ( int arr [], int size ){ for ( int i = 0 ; i < size - 1 ; i ++) { int minIndex = i ; for ( int j = i + 1 ; j < size ; j ++) { if ( arr [ j ]< arr [ minIndex ]) { minIndex = j ; } } swap ( arr [ minIndex ], arr [ i ]); } } int main (){ int arr [ 5 ]={ 34 , 4 , 56 , 78 , 3 }; sortingarr ( arr , 5 ); }

binary search 2

  #include <iostream> using namespace std ; // function for binary search : int Bsearch ( int arr [], int size , int key ){ int start = 0 ; int end = size - 1 ; int mid = ( start + end )/ 2 ; while ( start <= end ) { if ( arr [ mid ]== key ) { return mid ; } if ( arr [ mid ]< key ) { start = mid + 1 ; } else { end = mid - 1 ; } mid = ( start + end )/ 2 ; } return - 1 ; } int main (){ int marray [ 7 ] = { 22 , 33 , 44 , 55 , 66 , 77 , 88 }; int answer = Bsearch ( marray , 7 , 55 ); cout << " the index is : " << answer << endl ; return 0 ; }

binary search

  #include <iostream> using namespace std ; //funtion to print the square of given number : int square ; int fnding_square_number ( int n ){ square = n * n ; return square ; } //function for binary search. int binarysearching ( int arr [], int size , int key ){ int start = 0 ; int end = size - 1 ; int mid = ( start + end )/ 2 ; while ( start <= end ){ if ( arr [ mid ]== key ){ return mid ; } //go to the right waka part: if ( key > arr [ mid ]){ start = mid + 1 ; } else { end = mid - 1 ; } mid = ( start + end )/ 2 ; } return - 1 ; } int main (){ int arr [ 5 ]={ 12 , 13 , 14 , 15 , 16 }; int answer = binarysearching ( arr , 5 , 11 ); cout << answer ; }

swapping the alternate values in given array's element ! 17/11/2022

  #include <iostream> using namespace std ; // funtion to print the value of array; void printingarray ( int arr [], int size ){ for ( int i = 0 ; i < size ; i ++){ cout << arr [ i ] << " " ; } { /* code */ } } // funtion to swap the alternate value of an arra's element; void alternetswap ( int arr [], int size ){ for ( int i = 0 ; i < size ; i += 2 ) { if ( i + 1 < size ) { swap ( arr [ i ], arr [ i + 1 ]); } } } int main (){ int marry [ 6 ]={ 1 , 2 , 3 , 4 , 5 , 6 }; int garry [ 5 ]={ 23 , 43 , 56 , 76 , 4 }; alternetswap ( marry , 6 ); printingarray ( marry , 6 ); cout << endl ; alternetswap ( garry , 5 ); printingarray ( garry , 5 ); }

program to find the sum of element of given array

  #include <iostream> using namespace std ; // funtion to reverse the array void reverse ( int arr [], int size ){ int start = 0 ; int end = size - 1 ; while ( start <= end ) { swap ( arr [ start ], arr [ end ]); start ++; end --; } } // funtion to find the sum of elements of array; int sum = 0 ; void addingarray ( int arr [], int size ){ for ( int i = 0 ; i < size ; i ++) { sum = sum + arr [ i ]; } cout << endl ; } int main (){ int marray [ 5 ]={ 3 , 5 , 6 , 7 , 8 }; addingarray ( marray , 5 ); cout << sum ; }

reversing an array

#include <iostream> using namespace std ; void reverse ( int arr [], int size ){ int start = 0 ; int end = size - 1 ; while ( start <= end ) { swap ( arr [ start ], arr [ end ]); start ++; end --; } } void printingarr ( int arr [], int size ){ for ( int i = 0 ; i < size ; i ++) { cout << arr [ i ] << " " ; } } int main (){ int arr [ 10 ]= { 23 , 43 , 65 , 3 , 2 , 366 , 43 , 74 , 32 , 64 }; reverse ( arr , 10 ); printingarr ( arr , 10 ); }

reversing an arrray in c++

  #include <iostream> using namespace std ; void reverse ( int arr [], int size ){ int start = 0 ; int end = size - 1 ; while ( start <= end ){ swap ( arr [ start ], arr [ end ]); start ++; end --; } } void printingarr ( int arr [], int size ){ for ( int i = 0 ; i < size ; i ++) { cout << arr [ i ] << " " ; } } int main (){ int arr [ 5 ]={ 1 , 2 , 3 , 4 , 5 }; reverse ( arr , 5 ); printingarr ( arr , 5 ); }

liniera search in array

  #include <iostream> using namespace std ; bool search ( char listOfVowels [], int size , int key ){ for ( int i = 0 ; i < size ; i ++) { if ( listOfVowels [ i ]== key ) { return 1 ; } } return 0 ; }; int main (){ char listOfVowels [ 5 ]={ 'a' , 'e' , 'i' , 'o' , 'u' }; char key ; cout << "plz enter the key to search of : " ; cin >> key ; char found = search ( listOfVowels , 5 , key ); if ( found ) { cout << "yes it is present! " ; } else { cout << "No it is not preset!" ; } cout << found ; }

linear search in array

  #include <iostream> using namespace std ; bool search ( int arr [], int size , int key ){ for ( int i = 0 ; i < size ; i ++) { if ( arr [ i ]== key ) { return 1 ; } } return 0 ; } int main (){ int arr [ 10 ]={ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 }; int key ; cout << "plz enter the key to search of : " ;; cin >> key ; bool found = search ( arr , 10 , key ); if ( found ) { cout << "Yes it is present!" ; } else { cout << " No It is Absent " << endl ; } }