Weitere ähnliche Inhalte Ähnlich wie C Prog - Array Ähnlich wie C Prog - Array (20) Mehr von vinay arora (20) Kürzlich hochgeladen Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991 Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991 RKavithamani
Kürzlich hochgeladen (20) C Prog - Array1. C Programming - Array
Organized By: Vinay Arora
Assistant Professor, CSED
Thapar University, Patiala
2. Program - 1
#include<stdio.h> printf("Entered Numbers aren");
#include<conio.h> for(count=0;count<=4;count++)
{
void main() printf("%dn",num[count]);
}
{ getch();
int num[5]; }
int count;
clrscr();
printf("Enter five numbersn");
for(count=0;count<=4;count++)
{
scanf("%d",&num[count]);
}
Vinay Arora
CSED
4. Program - 2
#include<stdio.h> for(count=0;count<=4;count++)
#include<conio.h> {
sum=sum+marks[count];
void main() }
{
int marks[5]; printf("Total Markst%d",sum);
int count,sum=0; getch();
clrscr(); }
printf("Enter Marks of Five Studentsn");
for(count=0;count<=4;count++)
{
scanf("%d",&marks[count]);
}
Vinay Arora
CSED
6. Program - 3
#include<stdio.h>
#include<conio.h>
void main()
{
int num[26], temp ;
clrscr();
num[0] = 100 ;
num[25] = 200 ;
temp = num[25] ;
num[25] = num[0] ;
num[0] = temp ;
printf ( "n%d %d", num[0], num[25] ) ;
getch();
}
Vinay Arora
CSED
8. Program - 4
#include<stdio.h> for (count=0;count<=4;count++)
#include<conio.h> {
if(element==num[count])
void main() {
{ flag=1;
int num[5],element,count,flag; break;
clrscr(); }
else
printf("Enter the Array Elementsn"); flag=0;
for (count=0;count<=4;count++) }
{
scanf("%d",&num[count]); if(flag==1)
} printf("Element Found");
else
printf("Enter the Element to be Searchedt"); printf("Element Not Found");
scanf("%d",&element); getch();
}
Vinay Arora
CSED
9. Program - 4
#include<stdio.h> for (count=0;count<=4;count++)
#include<conio.h> {
if(element==num[count])
void main() {
{ flag=1;
int num[5],element,count,flag; break;
clrscr(); }
else
printf("Enter the Array Elementsn"); flag=0;
for (count=0;count<=4;count++) }
{
scanf("%d",&num[count]); if(flag==1)
} printf("Element Found");
else
printf("Enter the Element to be Searchedt"); printf("Element Not Found");
scanf("%d",&element); getch();
}
Vinay Arora
CSED
11. Program - 5
#include<stdio.h>
#include<conio.h>
void main()
{
int num[5],count;
clrscr();
printf("Enter the Array Elementsn");
for (count=0;count<=4;count++)
{
num[count]=count;
printf("%dn",num[count]);
}
getch();
}
Vinay Arora
CSED
13. Program - 6
#include<stdio.h>
#include<conio.h>
void main()
{
int num[5],count;
clrscr();
printf("Enter the Array Elementsn");
for (count=0;count<=10;count++)
{
printf("%dn",num[count]);
}
getch();
}
Vinay Arora
CSED
15. Program - 7
#include<stdio.h>
#include<conio.h>
void main()
{
int num[5]={22,4,77,8,9}
int count;
clrscr();
printf("Array Elements aren");
for (count=0;count<=4;count++)
{
printf("%dn",num[count]);
}
getch();
}
Vinay Arora
CSED
17. Program - 8
#include<stdio.h>
#include<conio.h>
void main()
{
int num[5]={22,4,77,8,9};
int count;
clrscr();
printf("Array Elements aren");
for (count=0;count<=15;count++)
{
printf("%dn",num[count]);
}
getch();
}
Vinay Arora
CSED
19. 2 – D Array
Vinay Arora
CSED
20. 2 – D Array Declaration
Vinay Arora
CSED
22. Program - 9
#include<stdio.h>
#include<conio.h>
void main()
{
int num[3][2]={10,1,20,2,30,3};
int count;
clrscr();
printf("Array Elements aren");
for (count=0;count<=2;count++)
{
printf("t%dt%dn",num[count][0],num[count][1]);
}
getch();
}
Vinay Arora
CSED
24. Program - 10
#include<stdio.h>
#include<conio.h>
void main()
{
int marks[2][3];
int count;
clrscr();
printf("Enter the marks for 1st studentn");
for (count=0;count<=2;count++)
{
printf("Enter marks in subject code -> %dt",count+1);
scanf("%d",&marks[0][count]);
}
printf("Enter the marks for 2nd studentn");
for (count=0;count<=2;count++)
{
printf("Enter marks in subject code -> %dt",count+1);
getch();
scanf("%d",&marks[1][count]); }
}
Vinay Arora
CSED
29. Program - 11
#include<stdio.h>
#include<conio.h>
void main()
{
int a=3;
clrscr();
printf("Value of variable a=%d",a);
printf("nAddress of variable a=%u",&a);
getch();
}
Vinay Arora
CSED
31. Program - 12
#include<stdio.h>
#include<conio.h>
void main()
{
int a[]={10,20};
int i;
clrscr();
for(i=0;i<=1;i++)
{
printf("Value of variable a[%d]=%d",i,a[i]);
printf("nAddress of variable a[%d]=%u",i,&a[i]);
printf("nn");
}
getch();
}
Vinay Arora
CSED
33. Program - 13
#include<stdio.h>
#include<conio.h>
void main()
{
int a[2][2]={10,20,30,40};
int i,j;
clrscr();
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
printf("Value of variable a[%d][%d]=%d",i,j,a[i][j]);
printf("nAddress of variable a[%d][%d]=%u",i,j,&a[i][j]);
printf("nn");
}
}
getch();
}
Vinay Arora
CSED
35. Program - 14
#include<stdio.h>
#include<conio.h>
void main()
{
int a=50;
clrscr();
printf("nValue of a=%d",a);
printf("nAddress of a=%u",&a);
printf("nn(Using pointer *)");
printf("nValue of a=%d",*(&a));
getch();
}
Vinay Arora
CSED
37. Program - 15
#include<stdio.h>
#include<conio.h>
void main()
{
int i=10;
int *j;
clrscr();
printf("nValue of i=%d",i);
printf("nAddress of i=%u",&i);
j=&i;
printf("nValue of j=%d",*j);
getch();
}
Vinay Arora
CSED