Lab 3.1 Complete the following code to find the largest number among the positiv
ID: 3837630 • Letter: L
Question
Lab 3.1 Complete the following code to find the largest number among the positive numbers that user entered. When the use enters a negative number the program stop taking input and prints out the result.
#include <stdio.h>
int main(void)
{
float x, max = 0.0f;
for (;;) {
printf("Enter a number: ");
}
printf(" "); /* blank line */
printf("The largest number entered was %g ", max);
return 0;
}
Lab 3.2 Write a program that finds the smallest number among 30 numbers that user entered. The 30 numbers are not necessarily positive. (Do not use array or other data structures).
Lab 3.3 Print the following numbers (first column contains odd number in ascending; second column contains even numbers in descending)
1 20
3 18
5 16
7 14
9 12
11 10
13 8
15 6
17 4
19 2
Lab 3.4 Print multiplication table:
Lab 3.5 Write a program that asks the use to enter some dates, then the program prints the earliest date the user entered. An input of 0/0/0 stops the program.
Lab 3.1 Complete the following code to find the largest number among the positive numbers that user entered. When the use enters a negative number the program stop taking input and prints out the result.
#include <stdio.h>
int main(void)
{
float x, max = 0.0f;
for (;;) {
printf("Enter a number: ");
}
printf(" "); /* blank line */
printf("The largest number entered was %g ", max);
return 0;
}
Lab 3.2 Write a program that finds the smallest number among 30 numbers that user entered. The 30 numbers are not necessarily positive. (Do not use array or other data structures).
Lab 3.3 Print the following numbers (first column contains odd number in ascending; second column contains even numbers in descending)
1 20
3 18
5 16
7 14
9 12
11 10
13 8
15 6
17 4
19 2
Lab 3.4 Print multiplication table:
Lab 3.5 Write a program that asks the use to enter some dates, then the program prints the earliest date the user entered. An input of 0/0/0 stops the program.
Explanation / Answer
#include <studio.h>
int main(void)
{
float x,max = 0.0f;
while(x>0)
{
Print ("enter the number");
scanf("%d",&x);
a[i]= x;
i++;
}
for(j=0;j<I;j++)
{
Printf("%d",a[j]);
}
}
#include<studio.h>
Int main()
{
int a[30],i,num,small;
Printf("enter the elements");
for(I=0;I<30;I++)
scanf ("%d",&a[I]);
small=a[0];
for (I=0;I<30;I++)
{
If(a[I]<small)
small=a[I];
}
}
printf("smallest element:%d",small);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.