C Program
C Program
#include <stdio.h>
int main() {
int year;
printf("Enter a year: ");
scanf("%d", &year);
return 0;
}
Output 1
Output 2
1#include<stdio.h>
2
3void main()
4{
5 int a,b,c;
6
7 printf("\n\nEnter three numbers=");
8 scanf("%d %d %d",&a,&b,&c);
9
1 if (a<b && a<c)
0 {
1 if(b<c)
1 {
1 printf("%d %d %d",a,b,c);
2 }
1 else
3 {
1 printf("%d %d %d",a,c,b);
4 }
1 }
5
1 else if (b<c && b<a)
6 {
1
7 if (c<a)
1 {
8 printf("%d %d %d",b,c,a);
1 }
9
2 else
0 {
2 printf("%d %d %d",b,a,c);
1 }
2
2 }
2
3 else if (c<a && c<b)
2 {
4
2 if (b<a)
5 {
2 printf("%d %d %d",c,b,a);
6 }
2
7 else
2 {
8 printf("%d %d %d",c,a,b);
2 }
9
3 }
0}
3
1
3
2
3
3
3
4
3
5
3
6
3
7
3
8
3
9
4
0
4
1
4
2
4
3
4
4
4
5
4
6
4
7
4
8
4
9
5
0
5
1
5.a
1. int main()
2. {
3. int n,sum=0,m;
4. printf("Enter a number:");
5. scanf("%d",&n);
6. while(n>0)
7. {
8. m=n%10;
9. sum=sum+m;
10. n=n/10;
11. }
12. printf("Sum is=%d",sum);
13. return 0;
14. }
6.c
#include <stdio.h>
2 void lcm_gcd(int ,int);
9
3 void main()
0{
3 int no1,no2;
1
3 printf("Enter two Numbers\n");
2 scanf("%d %d",&no1,&no2);
3 lcm_gcd(no1,no2);
3}
3
4 void lcm_gcd(int n1,int n2)
3{
5 int gcd,lcm,remainder,numerator,denominator;
3 if (n1>n2)
6 {
3 numerator=n1;
7 denominator=n2;
3 }
8 else
{
numerator=n2;
denominator=n1;
}
remainder=numerator%denominator;
while (remainder!=0)
{
numerator=denominator;
denominator=remainder;
remainder=numerator%denominator;
}
gcd = denominator;
lcm = n1*n2/gcd;
7.A
#include <stdio.h>
int main() {
int base, exponent, result = 1;
7.c
1. #include <stdio.h>
2. #include <conio.h>
3. void main()
4. {
5. int i, j, rows;
6. printf (" Enter a number to define the rows: \n ");
7. scanf("%d", &rows);
8. printf("\n");
9. for (i = 1; i <= rows; ++i) // outer loop
10. {
11. for (j = 1; j <= i; ++j) // inner loop
12. {
13. printf ("i "); // print the Star
14. }
15. printf ("\n");
16. }
17. getch();
18. }
7d.
8a
#include<stdio.h>
int main()
int a[50],i,n,large,small;
scanf(“%d”,&n);
for(i=0;i<n;++i)
scanf(“%d”,&a[i]);
large=small=a[0];
for(i=1;i<n;++i)
if(a[i]>large)
large=a[i];
if(a[i]<small)
small=a[i];
}
printf(“\nThe smallest element is %d\n”,small);
return 0;
OUTPUT
Enter the number of elements : 5
8b
#include <stdio.h>
#include <math.h>
#define MAXSIZE 10
void main()
{
float x[MAXSIZE];
int i, n;
float average, variance, std_deviation, sum = 0, sum1 = 0;
1b
#include<stdio.h>
#include<math.h>
int main()
int p,t;
float r,si,amount,ci;
scanf("%d%d%f",&p,&t,&r);
si=p*t*r/100;
amount=p*pow((1 +r/100),t);
ci=amount-p;