1. Print 1
Write a C program to print all numbers between a and b (a and b inclusive) using a for loop.
2. Print 2
Write a C program to print all numbers between a and b (a and b inclusive) using a for loop
code:
3. Print 3
Write a C program to print all numbers between a and b (a and b inclusive) using a for loop.
2. Print 2
Write a C program to print all numbers between a and b (a and b inclusive) using a for loop
code:
3. Print 3
Write a C program to print all numbers between a and b (a and b inclusive) using for loops.
4. Sum of 'n' numbers
Write a C program to find the sum of 'n' numbers using a for loop.
code:
5. Sum of 'n' positive numbers
Write a C program to that allows the user to enter 'n' numbers and finds the number of non-negative numbers entered and the sum of all positive numbers entered using a for loop.
code :
6. Count positive and negative
Write a C program to that allows the user to enter 'n' numbers and finds the number of positive numbers entered and the number of negative numbers entered using a for loop.
code:
#include<stdio.h> int main() | |
{ | |
int n,i,a,fp=0,fn=0; | |
printf("Enter the value of n\n"); | |
scanf("%d",&n); | |
for(i=1;i<=n;i++) | |
{ | |
printf("Enter the number\n"); | |
scanf("%d",&a); | |
if(a>=0) | |
fp++; | |
else | |
fn++; | |
} | |
printf("Number of positive numbers entered is %d and the number of negative numbers entered is %d\n",fp,fn); | |
return 0; | |
} |
7. Multiplication Table
Write a C program to print the multiplication table of an integer n upto m rows using a for loop
code:
8. Print 1
Write a C program to print all numbers between a and b (a and b inclusive) using a while loop.
code:
9. Print 2
Write a C program to print all numbers between a and b (a and b inclusive) using a while loop.
code:
10.Print 3
Write a C program to print all numbers between a and b (a and b inclusive) using while loops.
code:
11.
Sum of 'n' numbers
Write a C program to find the sum of 'n' numbers using a while loop.
code:
12. Sum of 'n' positive numbers
Write a C program to that allows the user to enter 'n' numbers and finds the number of positive numbers entered and the sum of all positive numbers entered using a while loop.
code:
13. Count positive and negative
Write a C program to that allows the user to enter 'n' numbers and finds the number of positive numbers entered and the number of negative numbers entered using a while loop.
code:
| ||
{ | ||
int n,a,fp=0,fn=0; | ||
printf("Enter the value of n\n"); | ||
scanf("%d",&n); | ||
while(n--) | ||
{ | ||
printf("Enter the number\n"); | ||
scanf("%d",&a); | ||
if(a>=0) | ||
fp++; | ||
else | ||
fn++; | ||
} | ||
printf("Number of positive numbers entered is %d and the number of negative numbers entered is %d\n",fp,fn); | ||
return 0; | ||
} |
14. Multiplication Table
Write a program to print the multiplication table of an integer n upto m rows using a while loop.
code:
15. Valid
No comments:
Post a Comment