Write A Program To Input Numbers An Integer Array and Display Them (By Use of Any Loop) - (CO4)
Write A Program To Input Numbers An Integer Array and Display Them (By Use of Any Loop) - (CO4)
Write A Program To Input Numbers An Integer Array and Display Them (By Use of Any Loop) - (CO4)
Write a program to input numbers an integer array and display them (by
use of any loop). (CO4)
#include<stdio.h>
int main()
{
int array[100],i,n;
printf("enter no of array \n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("array[%d] : ",i);
scanf("%d",&array[i]);
}
printf("array elements are \n");
for(i=0;i<n;i++)
printf("array[%d] : %d\n",i,array[i]);
return 0;
}
OUTPUT :
enter no of array 5
array[0] : array[1] : array[2] : array[3] : array[4] : array elements are
array[0] : 1
array[1] : 2
array[2] : 3
array[3] : 4
array[4] : 5
14. Write a program to add elements of two integer arrays and store in third
array and display that result array. (CO4)
#include<stdio.h>
int main()
{
int a[5],b[5],c[10],i,k;
printf("1st array \n");
for(i=0;i<5;i++)
{
printf("a[%d]",i);
scanf("%d",&a[i]);
}
printf("2nd array \n");
for(i=0;i<5;i++)
{
printf("b[%d]",i);
scanf("%d",&b[i]);
}
for(i=0;i<5;i++)
c[i] = a[i];
k=i;
for(i=0;i<5;i++)
{
c[k] = b[i];
k++;
}
printf("final array \n");
for(i=0;i<10;i++)
{
printf("a[%d] : %d\n",i,c[i]);
}
return 0;
}
OUTPUT :
1st array
a[0] - 0
a[1] - 1
a[2] - 2
a[3] - 3
a[4] - 4
2nd array
b[0] - 5
b[1] - 6
b[2] - 7
b[3] - 8
b[4] - 9
final array
a[0] : 0
a[1] : 1
a[2] : 2
a[3] : 3
a[4] : 4
a[5] : 5
a[6] : 6
a[7] : 7
a[8] : 8
a[9] : 9
15. Write a program to input characters in a char array and display them and
convert from capital to small (by use of any loop). (CO4).
#include<stdio.h>
int main()
{
char a[100],i=0;
printf("your name\n");
gets(a);
while(a[i] != '\0')
{
a[i] = a[i] + 32;
i++;
}
printf("%s",a);
return 0;
}
OUTPUT :
your name SIDDHAPURA YASH
siddhapurayash
16. Write a structure called student_data, store three members inside it called name,
gender and age and with help of that structure scan 5 student’s such data and display it
back on screen (use any one kind of loop to do it). (CO4)