* Write a program create 5 elements integer array to store zero's.
#include<stdio.h> #include<conio.h> void main() { int i,a[5]; clrscr(); for(i=0;i<5;i++) a[i]=0; for(i=0;i<5;i++) printf("%d\t",a[i]); getch(); } |
Output:-
* Write a program create 10 elements integer to store numbers from 0 to 9 print the array.
#include<stdio.h> #include<conio.h> void main() { int i,a[10]; clrscr(); for(i=0;i<10;i++) a[i]=i; for(i=0;i<10;i++) printf("%d\t",a[i]); getch(); } |
Output:-
* Write a program create 10 elements integer array to store natural numbers from 1 to 10 and print the array.
#include<stdio.h> #include<conio.h> void main() { int i,a[10]; clrscr(); for(i=0;i<10;i++) a[i]=i+1; for(i=0;i<10;i++) printf("%d\t",a[i]); getch(); } |
Output:-
* Write a program create 10 elements integer array to store even numbers and print the array.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,a[10];
clrscr();
for(i=0;i<10;i++)
{
a[i]=(i+1)*2;
}
for(i=0;i<10;i++)
printf("%d\t",a[i]);
getch();
}
|
Output:-
* Write a program to print 5 integer array values.
#include<stdio.h> #include<conio.h> void main() { int i,a[5]={10,35,20,55,15}; clrscr(); for(i=0;i<5;i++) { printf("a[%d] value is:%d\n",i,a[i]); } getch(); } |
Output:-
* Write a program to print 5 integer array values Using Arithmetic Operators.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5];
clrscr();
a[0]=20;
a[1]=30;
a[2]=a[0]*a[1];
a[3]=a[2]-a[1];
a[4]=a[3]+a[3];
printf("a[0] value is:%d\n",a[0]);
printf("a[1] value is:%d\n",a[1]);
printf("a[2] value is:%d\n",a[2]);
printf("a[3] value is:%d\n",a[3]);
printf("a[4] value is:%d\n",a[4]);
getch();
}
|
Output:-
_________________________________________
_______________________________________________________________________________
Post a Comment