WAP FOR FUNTION. WAP FOR WHILE LOOP.
#include<stdio.h> #include<stdio.h>
int sum(); int main(){
void main() int i=1;
{ while(i<=10){
int result; printf("%d \n",i);
printf("\nGoing to calculate the sum of two i++;
numbers:"); }
result = sum(); return 0;
printf("%d",result); }
}
int sum()
{ Output
int a,b; 1
printf("\nEnter two numbers"); 2
scanf("%d %d",&a,&b); 3
return a+b; 4
} 5
6
Output 7
Going to calculate the sum of two numbers: 8
Enter two numbers 10 9
24 10
The sum is 34
WAP TO PRINT MULTIPICATION TABLE.
#include <stdio.h>
int main() {
int n, i, range; Output
printf("Enter an integer: "); Enter an integer: 12
scanf("%d", &n); Enter the range (positive integer): -8
Enter the range (positive integer): 8
// prompt user for positive range 12 * 1 = 12
do { 12 * 2 = 24
printf("Enter the range (positive integer): ");
12 * 3 = 36
scanf("%d", &range);
12 * 4 = 48
} while (range <= 0);
12 * 5 = 60
for (i = 1; i <= range; ++i) { 12 * 6 = 72
printf("%d * %d = %d \n", n, i, n * i); 12 * 7 = 84
} 12 * 8 = 96
return 0;
}