Set 6 fundamental of programing file pagea

10D40TARUN 11 views 8 slides Oct 12, 2024
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

Programing


Slide Content

Lde Ldt Search Yiew Project Egecute Jools AStyle Window Help
(globals)
Project Classes Debug Set 6 no.1cpp
1
2
3
5
4
6
79
8
10
119
12
13
14
15 L
#include<stdio. h>
main(0
int i, a[5];
for (i=0;i<5; i++)
a[i]=i+1;
for(i=0;ic5; it+)
)
I
printf("%A ", a[i);
D2 29 Select CDevCpp\Set 6 no.1.exe
1 2
value 0
3 4
Process exited after 0.06046 seconds with
5
Press any key to continue

1
2
3
4
5
6
79
8
9
10
112
12
13
14
#include<stdio .h>
main()
15 L
int i,a[5];
for (i=0;i<5;i++)
ErrOrs: 0
a[i]=5-i;
for (i=0; ic5; i++)
es dh Compile Log Debug Find Results Close
printf("%A ", a[i]);
Camp1lation results.
Warnings: 0
5
CADev-Cpp\Set 6 no.2.exe
4 3 2 1
Process exited after 0.04727 seconds
with return value
Press any key to continue

Project Classes Debug Set 6 no.1.cpp Set 6 no.2.cpp Set 6 no.3.cpp
main()
4P{
6
11
12
2
10
13
14
15
3
5
#include<stdio.h>
int i,a[5], sum=0;
float average j
)
for(i=0;i<5; it+)
printf ("Enter Value : ");
scanf ("%d", &a[i]) ;
sum=sum+a[i];
average=sum/5.0;
CADev Cpp\Set 6 no.3.exe
Enter Value:2
Enter Value:3
Enter Value:4
Enter Value:5
Enter Value : 10
Sum=24 Average=4.800000
printf ("Sum=%d tAverage=*f", S um, average ); Process exited after 5.205 secon
ds with return value O
Press any key to continue
X

ew Project Execute Jools AStyle Window Help
ls)
11
2
10
4
6
7
8
Set 6 no. 1.cpp Set 6 no.2.cpp Set 6 no.3.cpp Set 6 no.4.cpp
1
2
3
4
AA9|e 88 8HOW many numbers?10
#include<stdio.h>
main()
)
int i, a[100] , n, max, min;
printf("How many numbers?");
scanf("%d", &n);
for (i=0;i cn; i++)
printf(" Enter Value: ");
scanf( "Kd", &a[i]);
max=a[0]
min=a[0] ;
for (i=0;icn; i++)
1f(a[i] <min)
min=a[i];
if(a[i] >max)
maxza[i];
printf("Min=%d Max=%d", min, max) ;
Enter Value:10
Enter Value: 11
Enter Value: 12
Enter Value : 13
Enter Value : 14
Enter Value :15
Enter Value :16
Enter Value:17
Entgr Value : 18
Enter Value :19
Min=10 Max=19

1
2
#include<stdio .h>
main()
int i, a[100] , n, pos=0, neg=0,z=0;
printf("How many numbers ?");
scanf("%d", &n);
for(i=0;icn;i+)
)
printf("Enter Value : ");
scanf("%d", &a[i]);
for(i=0;icn;i++)
if (a[i]>e)
pos+t;
else if(a[i] <e)
else
neg++;
z++j
print f("Positive=%d Negative=%d Zeros=%d", pos, neg, z) ;
How many numbers?6
Enter Value: 23
Enter Value: -87
Enter Value :95
Enter Value: -54
Enter Value:24
Enter Value :0
Positive=3 Negative=2
return value
Process exited after 20.42 seconds with
Zeros=1
Press any key to continue

#includecstdio.h>
main()
int i, a[100] ,n, odd=0, even=0;
printf("How many numbers?") ;
scanf ("%d", &n)
for(i=0;i<ngi++)
printf("Enter Value : ");
scanf("%A" , &a[i);
for (i=0;i<n;it+)
if (a[ij%2 ==0)
else
even++j
odd++j
printf("Odd=%d Even=%d", odd, even) ;
CADev-Cpp\Set 6 no.6.exe
Enter Value: 21
Enter Value:56
Enter Value:75
Odd=2 Even=1
Process exited after 10.34 seconds with
return valuee
Press any key to continue

#include<stdio .h>
main()
int i,j, k, a[100 ],n,temp;
printf ("How many numbers?") ;
scanf ("%d", &n) ;
for (i=0;i<n; i++)
printf("Enter Value:");
scanf ("%d", &a[i]);
for (i=0;i<n;i++)
k=i;
for (j=i+1;j<n;j++)
{
}
{
if (a[j] <a[ K])
k=j; // Find index of the minimum
if (k! =i)//RepLace it.
temp=a[i];
a[i] =a[K];
a[k]=temp;
printf ("After sorting : ");
for (i=0;i<n;i++)
printf("%d", a[i]);
How many numbers?7
Enter Value : 24
Enter Value : 51
Enter Value : -10
Enter Value : 87
Enter Value : 65
Enter Value:48
Enter Value: 33
After sorting:
-10
24
33
48
51
65
Select C\DCpp\Set 6 no.6.exe
87
Process exited after 14.22 seconds wi

#include<stdio.h>
main()
int i,j, a[1e) [1¬),r,c;
printf ("How many rows?");
scanf ("%d",&r);
printf ("How many columns?");
scanf ("%d", 8c);
for (i=8; i<r;i++)
for (j=e;j<c;j++)
printf ("Enter value:");
Scanf ("%d", &a[i] [il) ;
printf("original Matrix:") ;
for (i=e;i<r;i+)
for (j=e;j<c;j++)
printf("%d", a[i] [3]);
printf("");
printf ("Transpose of Matrix: ") ;
for (i=@;i<c;i+)
for (j=e;j<r;j++)
printf("%d", a[j] [i));
printf("");
Enter Value:6
Enter Value:5
Enter Value:9
CADev-Cpp\Set f no.6.exe
Original Matrix:
26
59
Transpose of Matrix:
25
69
Process exited after 6.696 secon
ds with return value
Press any key to continue