OUTLINE 1)How to declare and define one dimensional array. 2)How To access Array Element. 3)How to initialize one dimensional array. ( NOTE: Size of integer is 4 bytes). 1) (The length of array can be specified by any integer constant expression. int arr[5]; int arr[5+5]; int arr[21/3]; int arr[4*3]; Specifying the length of an array using MACRO is considered to be an excellent practice. # define N 10 int arr[N]; 2)I NITIALIZING 1D ARRAY METHOD-1: [NOT TOO MUCH USED] arr[5]={2,3,4,5,5}; METHOD-2: arr[]={1,23,34,45,6}; METHOD:3 [NOT USEFUL] int arr[3]; int arr[0]=1; int arr[1]=2 int arr[2]=12; METHOD:4 int arr[5]; for(int i=1;i<5;i++) { scanf("%d",&arr[i]); } SUMMARY 1)IF THE NO, OF ELEMENT ARE LESS THAN THE LENGTH OF THE ARRAY THAN THE REST OF THE LOCATION ARE AUTOMATICALLY FILLED BY VALUE 0; 2)EASY WAY TO INITIALISE AN ARRAY WITH ALL ZEROS IS GIVEN BY: int arr[10]={0}; 3)AT THE TIME OF INITIALIZATION ,NEVER LEAVE THESE FLOWER BRACKET{} EMPTY AND ALSO NEVE...
#include<stdio.h> int main() { int a=64,n; char ch; printf("Enter The Range= "); scanf("%d",&n); for(int i=n;i>=1;i--) { for (int j=1;j<=i;j++) { ch=(char)a+j; printf(" %c ",ch ); } printf("\n"); } } Enter The Range= 7 A B C D E F G A B C D E F A B C D E A B C D A B C A B A
# include <stdio.h> int main () { int i, j; char input, alphabet = 'A' ; printf ( "Enter an uppercase character you want to print in the last row: " ); scanf ( "%c" , &input); for (i = 1 ; i <= (input - 'A' + 1 ); ++i) { for (j = 1 ; j <= i; ++j) { printf ( "%c " , alphabet); } ++alphabet; printf ( "\n" ); } return 0 ; }
Comments
Post a Comment