C Programming - ArrayOrganized By: Vinay Arora               Assistant Professor, CSED               Thapar University, Pa...
Program - 1 #include<stdio.h>                       printf("Entered Numbers aren"); #include<conio.h>                     ...
Program – 1 (output)                Vinay Arora                   CSED
Program - 2 #include<stdio.h>                        for(count=0;count<=4;count++) #include<conio.h>                      ...
Program – 2 (output)                Vinay Arora                   CSED
Program - 3          #include<stdio.h>          #include<conio.h>           void main()            {             int num[2...
Program – 3 (output)                Vinay Arora                   CSED
Program - 4#include<stdio.h>                                  for (count=0;count<=4;count++)#include<conio.h>             ...
Program - 4#include<stdio.h>                                  for (count=0;count<=4;count++)#include<conio.h>             ...
Program – 4 (output)                Vinay Arora                   CSED
Program - 5         #include<stdio.h>         #include<conio.h>         void main()          {           int num[5],count;...
Program – 5 (output)                Vinay Arora                   CSED
Program - 6         #include<stdio.h>         #include<conio.h>         void main()          {           int num[5],count;...
Program – 6 (output)                Vinay Arora                   CSED
Program - 7         #include<stdio.h>         #include<conio.h>         void main()          {           int num[5]={22,4,...
Program – 7 (output)                Vinay Arora                   CSED
Program - 8         #include<stdio.h>         #include<conio.h>         void main()          {           int num[5]={22,4,...
Program – 8 (output)                Vinay Arora                   CSED
2 – D Array              Vinay Arora                 CSED
2 – D Array Declaration                Vinay Arora                   CSED
Memory Representation               Vinay Arora                  CSED
Program - 9       #include<stdio.h>       #include<conio.h>        void main()         {          int num[3][2]={10,1,20,2...
Program – 9 (output)                Vinay Arora                   CSED
Program - 10  #include<stdio.h>  #include<conio.h>  void main()   {    int marks[2][3];    int count;    clrscr();   print...
Program – 10 (output)                Vinay Arora                   CSED
Pointer Notation                   Vinay Arora                      CSED
Pointer Notation (Conti…)                Vinay Arora                   CSED
Pointer Notation (Conti…)                Vinay Arora                   CSED
Program - 11        #include<stdio.h>        #include<conio.h>        void main()         {          int a=3;          clr...
Program – 11 (output)                Vinay Arora                   CSED
Program - 12       #include<stdio.h>       #include<conio.h>       void main()        {         int a[]={10,20};         i...
Program – 12 (output)                Vinay Arora                   CSED
Program - 13       #include<stdio.h>       #include<conio.h>       void main()        {         int a[2][2]={10,20,30,40};...
Program – 13 (output)                Vinay Arora                   CSED
Program - 14         #include<stdio.h>         #include<conio.h>          void main()           {            int a=50;    ...
Program – 14 (output)                Vinay Arora                   CSED
Program - 15        #include<stdio.h>        #include<conio.h>        void main()         {          int i=10;          in...
Program – 15 (output)                Vinay Arora                   CSED
Thnx…  Vinay Arora     CSED
Upcoming SlideShare
Loading in …5
×

C Prog - Array

545
-1

Published on

Published in: Education, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
545
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
55
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

C Prog - Array

  1. 1. C Programming - ArrayOrganized By: Vinay Arora Assistant Professor, CSED Thapar University, Patiala
  2. 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
  3. 3. Program – 1 (output) Vinay Arora CSED
  4. 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
  5. 5. Program – 2 (output) Vinay Arora CSED
  6. 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
  7. 7. Program – 3 (output) Vinay Arora CSED
  8. 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. 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
  10. 10. Program – 4 (output) Vinay Arora CSED
  11. 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
  12. 12. Program – 5 (output) Vinay Arora CSED
  13. 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
  14. 14. Program – 6 (output) Vinay Arora CSED
  15. 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
  16. 16. Program – 7 (output) Vinay Arora CSED
  17. 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
  18. 18. Program – 8 (output) Vinay Arora CSED
  19. 19. 2 – D Array Vinay Arora CSED
  20. 20. 2 – D Array Declaration Vinay Arora CSED
  21. 21. Memory Representation Vinay Arora CSED
  22. 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
  23. 23. Program – 9 (output) Vinay Arora CSED
  24. 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
  25. 25. Program – 10 (output) Vinay Arora CSED
  26. 26. Pointer Notation Vinay Arora CSED
  27. 27. Pointer Notation (Conti…) Vinay Arora CSED
  28. 28. Pointer Notation (Conti…) Vinay Arora CSED
  29. 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
  30. 30. Program – 11 (output) Vinay Arora CSED
  31. 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
  32. 32. Program – 12 (output) Vinay Arora CSED
  33. 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
  34. 34. Program – 13 (output) Vinay Arora CSED
  35. 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
  36. 36. Program – 14 (output) Vinay Arora CSED
  37. 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
  38. 38. Program – 15 (output) Vinay Arora CSED
  39. 39. Thnx… Vinay Arora CSED
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×