- #include<stdio.h>
{
int i,j;
for(i=1;i<=6;i++)
{
for(j=1;j<=i;j++)
{
printf("*
");
}
printf("\n");
}
- #include<stdio.h>
int
main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=7;j++)
{
printf("*
");
}
printf("\n");
}
}
- #include<stdio.h>
int
main()
{
int i,j;
for(i=1;i<=6;i++)
{
for(j=1;j<=7-i;j++)
{
printf("*
");
}
printf("\n");
}
}
- #include<stdio.h>
int
main()
{
int i,s,j;
for(i=1;i<=6;i++)
{
for(s=1;s<=6-i;s++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*
");
}
printf("\n");
}
}
- #include<stdio.h>
int main()
{
int
i,s,j;
for(i=1;i<=6;i++)
{
for(s=0;s<=i;s++)
{
printf(" ");
}
for(j=6;j>=i;j--)
{
printf("*
");
}
printf("\n");
}
}
- #include<stdio.h>
int
main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d
",j);
}
printf("\n");
}
}
int main
()
{
int a,b=10,c=20;
printf("value of b before swap
: %d\n",b);
printf("value of c before swap
: %d\n",c);
a=b;
b=c;
c=a;
printf("value of b after swap :
%d\n",b);
printf("value of c after swap :
%d\n",c);
return 0;
}
3. #include <stdio.h>
int main()
{
int no_of_Houses = 20;
int unitsPerHouse, i;
float totalBill = 0.0;
printf("Enter the number of units consumed by each house:\n");
for (i = 0; i < no_of_Houses; i++)
{
printf("House %d: ", i + 1);
scanf("%d",
&unitsPerHouse);
if (unitsPerHouse <= 50)
totalBill += unitsPerHouse * 0.5;
else if (unitsPerHouse <= 150)
totalBill += (50 * 0.5) +
(unitsPerHouse - 50) * 0.75;
else if (unitsPerHouse <= 250)
totalBill += (50 * 0.5) + (100 *
0.75) + (unitsPerHouse - 150) * 1.20;
else
totalBill += (50 * 0.5) + (100 * 0.75) + (100 * 1.20) + (unitsPerHouse - 250) * 1.50;
}
totalBill += totalBill * (20.0 / 100.0);
printf("Total electricity bill for the village: %.2f\n", totalBill);
return 0;
}
{
int num[10];
int min, max;
int i;
for (i = 0; i < 10; i++)
{
printf("Enter %d numbers:\n",i+1);
}
{
{
continue;
}
max = num[i];
}
return 0;
}
5. #include <stdio.h>
{
int i;
printf("n\t\tn*n\n");
for(i=1;i<=10;i++)
return 0;
}
6. #include <stdio.h>
int main()
{
int i,n;
float sum = 0;
printf("Input the number of terms: ");
scanf("%d", &n);
printf("1/1");
for (i = 2; i <= n; i++)
{
printf(" + 1/%d", i);
sum += 1.0 / i;
}
printf("\n");
printf("Sum of Series upto %d terms: %f\n", n, sum + 1);
return 0;
}
7. #include <stdio.h>
int main ()
{
int x , y;
float total = 0;
float average ;
int number;
for(x = 1; x <= 10; x++)
{
printf("Enter the number : ");
scanf("%i", &number);
total += number;
}
average = total / 10;
printf("Total : %f\n", total);
printf("Average : %.2f\n", average);
return 0;
}
0 Comments
Post a Comment