Loop and control in c
#include <stdio.h>
int main()
{
int i, sum = 0;
for (int i = 1; i <= 10; i++)
{
sum = sum + 8 * i;
printf("the sum first 8 table multi is %d \n", sum);
}
return 0;
}
#include <stdio.h>
int main()
{
int num = 8;
while (num == 8)
{
printf("%d", num);
}
return 0;
}
#include <stdio.h>
int main()
{
int num;
printf("enter which table U want :");
scanf("%d", &num);
for (int i = 10; i; i--)
{
printf("%d*%d=%d \n", num, i, num * i);
}
return 0;
}
#include <stdio.h>
int main()
{
int i=1,sum=0;
do{
sum=sum+i;
printf("the sum of first 10 natural number is %d\n",sum);
i++;
}while(i<=10);
return 0;
}
# include<stdio.h>
int main(){
int fac=1,num;
printf("enter the number fac u want :");
scanf("%d",&num);
for (int i = 1; i <=num; i++)
{
fac*=i;
}
printf("the value of %d! is %d",num,fac);
return 0;
}
#include <stdio.h>
int main()
{
int sum = 0;
for (int i = 1; i <= 10; i++)
{
sum = sum + i;
printf("the sum of natural number is %d \n", sum);
}
return 0;
}
#include <stdio.h>
int main()
{
int i, j, n;
printf("Enter the n number of tables:");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (j = 1; j <= 10; j++)
{
printf("the value is %d\n", i * j);
}
}
return 0;
}
#include <stdio.h>
int main()
{
int i, num, prime = 1;
printf("Enter The Number to verify prime Or Not:");
scanf("%d", &num);
for (int i = 2; i < num; i++)
{
if (num % i == 0)
{
prime = 0;
break;
}
}
if (prime == 0)
{
printf("this is not a prime Number");
}
else
{
printf("This is a prime Number");
}
return 0;
}
#include <stdio.h>
int main()
{
int i, j;
for (i = 10; i; i--)
{
for (j = 1; j <= 10; j++)
{
printf("the value is %d\n", i * j);
}
}
return 0;
}
#include <stdio.h>
int main()
{
int num, sum = 0;
printf("Enter the sum of n natural num U want?:");
scanf("%d", &num);
for (int i = 1; i <= num; i++)
{
sum += i;
}
printf("the sum of sigma(1-num) is %d", sum);
return 0;
}
#include <stdio.h>
int main()
{
int i = 1, sum = 0, num;
printf("Enter the n natural number Sum U want:");
scanf("%d", &num);
while (i <= num)
{
sum += i;
i++;
}
printf("the sum of sigma(1-num): %d", sum);
return 0;
}
#include <stdio.h>
int main()
{
int i = 1, sum = 0;
while (i <= 10)
{
sum = sum + i;
printf("The sum of value is %d \n", sum);
i++;
}
return 0;
}
#include <stdio.h>
int main()
{
int n = 0;
while (n < 10)
{
printf("The sum of first n natural n is %d\n", n + 1);
n++;
}
return 0;
}
#include <stdio.h>
int main()
{
int i = 1, sum = 0, num;
printf("Enter the sum of natural number U want :");
scanf("%d", &num);
while (i <= num)
{
sum = sum + i;
printf("The sum of natural number is %d\n", sum);
i++;
}
return 0;
}
No comments:
Post a Comment